/** 
Copyright (c) 2010, Sheikh Abdul Wahid Ahmed
Details @ http://extremecodeworld.codeplex.com/license
**/

using System;
using CodeGenerator.Definitions;
using System.Text;
using System.Reflection;
using EXtremecode.Logging;
using EXtremecode.Utils;
using EXtremecode.Common;
using CodeGenerator.Managers;	

namespace CodeGenerator {
public class CodeGeneratingClass {
public static string ASPXBOListSearchFrame(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


		
				
		//overriding entity.
		Entity entityBOPage =  RepositoryManager.Instance.Entities["BOPage",entityName];
		Entity entityBOListSearch =  RepositoryManager.Instance.Entities["BOListSearch",entityName];
		if(entityBOPage != null)
		{
			entityBOPage.OverridingEntity = entityBOListSearch;
		}
		entity.OverridingEntity = entityBOPage;
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <uasp:Frame runat=\"server\" ID=\"searchFrame\" Title=\"<%$ resources:");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(",SearchFrameTitle %>\" Width=\"100%\">" + "\r\n" + codeGeneratorVariable_Prefix + "        <uasp:FrameHeader>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            <uasp:FCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				<%-- Exporting Buttons --%>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                <table>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    <tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        <td >");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <asp:ImageButton ID=\"btnExcelExport\" Visible=\"false\" ImageUrl=\"~/Images/exportxls.gif\" runat=\"server\" OnClick=\"btnExcelExport_Click\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        <td >");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <asp:ImageButton ID=\"btnWordExport\" Visible=\"false\" ImageUrl=\"~/Images/exportdoc.gif\" runat=\"server\" OnClick=\"btnWordExport_Click\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    </tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                </table>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                <%-- /Exporting Buttons --%>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            </uasp:FCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        </uasp:FrameHeader>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        <uasp:FRow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            <uasp:FCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				<asp:ValidationSummary id=\"vldrSummary\" runat=\"server\" HeaderText=\"\"");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    ShowSummary=\"False\" ShowMessageBox=\"True\" ForeColor=\"#FF0000\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				<%--Table for applying indentation --%>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				<table width=\"100%\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    <tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						<td rowspan=\"2\" width=\"1\">&nbsp;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						</td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        <td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <br />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <uasp:FrameWindow runat=\"server\" ID=\"searchFrameWindow\" OnInit= \"SearchFrameWindow_OnInit\">");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		int fieldIndex=0;
		int pairsCount=entity.FieldsCountInSingleRow;
		bool rangeHalfCompleted=false;
		
		bool noFieldDisplayed = true;
		foreach(string entityFldKey in entity.Fields.Keys)
		{
			Entity.Field entityFld = entity.Fields[entityFldKey];
			if(entityFld.Displayed)
			{
				noFieldDisplayed = false;
				break;
			}
		}
		
		while(fieldIndex<entity.SortedFields.Count && !noFieldDisplayed)
		{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								<uasp:FRow>");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

	
			for(int i=0; i<pairsCount && fieldIndex<entity.SortedFields.Count;)
			{
				Entity.Field entityField = entity.SortedFields[fieldIndex];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


				if(dataType=="shortbinary" || dataType =="binary" || !displayed)
				{
					//move to next filed but dont increase 'i' pointer 
					fieldIndex++;
					continue;
				}
				else
				{
					//increase 'i' pointer
					i++;
				}
				
				string usedControl = (listTable == string.Empty)? webControl: listControl;
				string suffix = string.Empty;
				if(usingRange)
				{
					if(rangeHalfCompleted)
					{
						suffix = "_To";
						rangeHalfCompleted=false;
						fieldIndex++ ; //next time use other field.
					} 
					else
					{
						suffix = "_From";
						rangeHalfCompleted = true; //next time use same field for suffix 'To'
					}
				}
				else
				{
					//it has been consumed.
					fieldIndex++;
				}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<uasp:WCell  CssClass=\"fwCellCaption\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                        <asp:Label ID=\"lbl");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(suffix);

codeGeneratorVariable_DisplayCode.Append("\" runat=\"server\" Text=\"<%$ resources:" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(",Field_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(suffix);

codeGeneratorVariable_DisplayCode.Append(" %>\"/>" + "\r\n" + codeGeneratorVariable_Prefix + "                                    </uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    <uasp:WCell CssClass=\"fwCellValue\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                        <uasp:");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(usedControl);

codeGeneratorVariable_DisplayCode.Append(" ID=\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(suffix);

codeGeneratorVariable_DisplayCode.Append("\" runat=\"server\" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(strIsDecimalNumberAttb);

codeGeneratorVariable_DisplayCode.Append(" Caption = \"<%$ resources:" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(",Field_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(suffix);

codeGeneratorVariable_DisplayCode.Append(" %>\" IsReadOnly=\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(strReadOnly);

codeGeneratorVariable_DisplayCode.Append("\" DisplayCssClass = \"awFrameWindowValue\" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityField.ASPXAttributes);

codeGeneratorVariable_DisplayCode.Append("  />" + "\r\n" + codeGeneratorVariable_Prefix + "                                    </uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

	
			}
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + codeGeneratorVariable_Prefix + "								</uasp:FRow>	");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <%-- Custom Region Start [CustomSearchFields] --%>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <%-- Custom Region End --%>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            </uasp:FrameWindow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    </tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    <tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        <td >");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <asp:Table   runat=\"server\" Width=\"1\" ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(searchButtonsPanelAttributes);

codeGeneratorVariable_DisplayCode.Append(" >" + "\r\n" + codeGeneratorVariable_Prefix + "                                <asp:TableRow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    <asp:TableCell style=\"width: 100px\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                        <uasp:ASCXButton ID=\"btnSearch\" IsDefault=\"true\" runat=\"server\" OnClick=\"btnSearch_Click\" Text=\"<%$ resources:GeneralResource,Caption_Search %>\" ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(searchButtonAttributes);

codeGeneratorVariable_DisplayCode.Append(" />" + "\r\n" + codeGeneratorVariable_Prefix + "                                    </asp:TableCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    <asp:TableCell style=\"width: 100px\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                        <uasp:ASCXButton ID=\"btnReset\" runat=\"server\" Text=\"<%$ resources:GeneralResource,Caption_Reset %>\" OnClientClick=\"ResetSearchPanel()\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    </asp:TableCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                </asp:TableRow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            </asp:Table>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <br />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    </tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                </table>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            </uasp:FCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        </uasp:FRow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    </uasp:Frame>");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string ASPXBOListSearchFrame()
{ return ASPXBOListSearchFrame(string.Empty);}
public static string RefEntityIncludes(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 

	/*string refClassName=  StringProcessor.Class(refEntity.Name) + "BO";
    string refCollectionName=  refClassName + "Collection";
	string refEntityName=  refEntity.Name;
	string refEntityCaption = refEntity.Caption;
	string refEntityVariable = StringProcessor.Variable(refEntity.Name);
	string refTableName=refEntity.TableName; 
	string refViewName=refEntity.ViewName;
	string refKeySignature=refEntity.KeySignature;*/
 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string RefEntityIncludes()
{ return RefEntityIncludes(string.Empty);}
public static string BOListPopulateListControls(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


				
		//overriding entity.
		Entity entityBOPage =  RepositoryManager.Instance.Entities["BOPage",entityName];
		Entity entityBOListSearch =  RepositoryManager.Instance.Entities["BOListSearch",entityName];
		if(entityBOPage != null)
		{
			entityBOPage.OverridingEntity = entityBOListSearch;
		}
		entity.OverridingEntity = entityBOPage;
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        private void PopulateListControls()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			IListControl ctrl = null;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


        foreach(string entityFieldKey in entity.Fields.Keys)
        {
            Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


            if(listTable != string.Empty && displayed)
            {
			codeGeneratorVariable_DisplayCode.Append(Environment.NewLine + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            //**");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ctrl = ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[listControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(listTableCollectionName);

codeGeneratorVariable_DisplayCode.Append(" col" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(" = " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(listTableCollectionName);

codeGeneratorVariable_DisplayCode.Append(".Instance;" + "\r\n" + codeGeneratorVariable_Prefix + "			ctrl.Enumerable=col");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "			ctrl.FormatString = \"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(formatString);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n" + codeGeneratorVariable_Prefix + "			ctrl.KeyField = ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(listTableClassName);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(listTableKeyFieldConstant);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "			ctrl.DisplayFieldList = new string[] {");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				string qoma="";			  
                foreach(string displayField in listTableDisplayFields.Split(','))
                {
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(qoma);

codeGeneratorVariable_DisplayCode.Append(listTableClassName);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.ConstantNStatic(displayField));

codeGeneratorVariable_DisplayCode.Append("" + "" + "");


					qoma = ","; 
                }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			};");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			/** Custom Region Start [ListControl(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(")] **/" + "\r\n" + codeGeneratorVariable_Prefix + "			/** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ctrl.DataBind();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


            }  
        }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BOListPopulateListControls()
{ return BOListPopulateListControls(string.Empty);}
public static string BOListRowToControl(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


								
		//overriding entity.
		Entity entityBOPage =  RepositoryManager.Instance.Entities["BOPage",entityName];
		Entity entityBOListGrid =  RepositoryManager.Instance.Entities["BOListGrid",entityName];
		if(entityBOPage != null)
		{
			entityBOPage.OverridingEntity = entityBOListGrid;
		}
		entity.OverridingEntity = entityBOPage;
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected void RowToControl(Control control, ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow row)" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


            foreach(string entityFieldKey in entity.Fields.Keys)
            {
                Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


				if(!displayed)
				{
					continue;
				}
				if(dataType == "shortbinary" || dataType == "binary")
				{
					//will handle it later
					continue;
				}
				codeGeneratorVariable_DisplayCode.Append(Environment.NewLine + Environment.NewLine);
				string usedControl = (listTable == string.Empty)? webControl: listControl;
                if(listTable == string.Empty)
                {
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			//**");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(usedControl);

codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(" = control.FindControl(\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("\") as " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(usedControl);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "			if (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(" != null)" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(".Value = " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(strDecimalCast);

codeGeneratorVariable_DisplayCode.Append(" row.Value_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				}  
				else  //for list control
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			//**");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(usedControl);

codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(" = control.FindControl(\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("\") as " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(usedControl);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "			if (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(" != null)" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(usedControl);

codeGeneratorVariable_DisplayCode.Append(" ctrl =  " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "				if (row.Value_");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(" != null)" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(listTableCollectionName);

codeGeneratorVariable_DisplayCode.Append(" col = " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(listTableCollectionName);

codeGeneratorVariable_DisplayCode.Append(".Instance;" + "\r\n" + codeGeneratorVariable_Prefix + "					ctrl.Enumerable=col;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					ctrl.FormatString = \"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(formatString);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n" + codeGeneratorVariable_Prefix + "					ctrl.IsRequired = true;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					ctrl.KeyField = ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(listTableClassName);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(listTableKeyFieldConstant);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "					ctrl.DisplayFieldList = new string[] {");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


					string qoma="";			  
					foreach(string displayField in listTableDisplayFields.Split(','))
					{
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(qoma);

codeGeneratorVariable_DisplayCode.Append(listTableClassName);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.ConstantNStatic(displayField));

codeGeneratorVariable_DisplayCode.Append("" + "" + "");


						qoma = ","; 
					}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					};");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					col.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(listTableKeyFieldProperty);

codeGeneratorVariable_DisplayCode.Append(" = row.Value_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "					ctrl.DataBind();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    ctrl.Value = row.Value_");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				else");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					ctrl.Value = null;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


                }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

	
            }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BOListRowToControl()
{ return BOListRowToControl(string.Empty);}
public static string ASPXBOEditWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;
		//overriding entity.
		Entity entityBOPage =  RepositoryManager.Instance.Entities["BOPage",entity.Name];
		Entity entityBOEditPage =  RepositoryManager.Instance.Entities["BOEditPage",entity.Name];
		if(entityBOPage != null)
		{
			entityBOPage.OverridingEntity = entityBOEditPage;
		}
		entity.OverridingEntity = entityBOPage;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "<%@ Page Language=\"C#\" MasterPageFile=\"~/DefaultMasterPage.master\" AutoEventWireup=\"true\"");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ValidateRequest=\"false\" CodeFile=\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Edit.aspx.cs\" Inherits=\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(RepositoryManager.Instance.Repository.ProjectName);

codeGeneratorVariable_DisplayCode.Append(".Aspx." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(accessorName);

codeGeneratorVariable_DisplayCode.Append("." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Edit\" %>" + "\r\n" + codeGeneratorVariable_Prefix + "<asp:Content ID=\"Content1\" ContentPlaceHolderID=\"Content\" runat=\"Server\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		codeGeneratorVariable_DisplayCode.Append(ASPXBOEditJaveScript() + Environment.NewLine);
		codeGeneratorVariable_DisplayCode.Append(ASPXBOEditFrame() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "</asp:Content>	");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string ASPXBOEditWholeClass()
{ return ASPXBOEditWholeClass(string.Empty);}
public static string Login(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "<!-- for keeping window in center -->");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <script language=\"javascript\" type=\"text/javascript\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "     function ResetControls()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "     {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        document.getElementById(\"<%=txtLogin.ClientID%>\").ResetValue();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        document.getElementById(\"<%=txtPassword.ClientID%>\").ResetValue();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "     }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    </script>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "    <asp:ValidationSummary ID=\"vldrSummary\" runat=\"server\" HeaderText=\"\" ShowSummary=\"False\"");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        ShowMessageBox=\"True\" ForeColor=\"#FF0000\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"background-color: azure\"");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        width=\"100%\" height=\"200\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        <tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            <td width=\"35%\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            <td style=\"vertical-align: middle; text-align: center\" align=\"center\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                <!-- for keeping buttons with window -->");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                <table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" style=\"vertical-align: top; text-align: left\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    <tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        <td colspan=\"2\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <asp:Label ID=\"lblErrorMessage\" runat=\"server\" EnableViewState=\"false\" Style=\"color: Red\"></asp:Label>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    </tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    <tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        <td colspan=\"2\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <uasp:FrameWindow ID=\"frameLogin\" ImageURL=\"~/images/Login.gif\" Title=\"<%$ resources:GeneralResource,Title_Login %>\"");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                runat=\"server\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                <uasp:FRow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    <uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        <asp:Label ID=\"lblLogin\"  runat=\"server\" Text=\"<%$ resources:GeneralResource,Caption_LoginName %>\"/>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    </uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    <uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "       <uasp:ASCXTextBox  ID=\"txtLogin\" IsRequired=\"true\" runat=\"server\" Caption=\"<%$ resources:GeneralResource,Caption_LoginName %>\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    </uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                </uasp:FRow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                <uasp:FRow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    <uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                            <asp:Label ID=\"lblPassword\" runat=\"server\"  Text=\"<%$ resources:GeneralResource,Caption_Password %>\"/>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    </uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    <uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                        <uasp:ASCXTextBox ID=\"txtPassword\" runat=\"server\" IsRequired=\"true\" TextMode=\"Password\" Caption=\"<%$ resources:GeneralResource,Caption_Password %>\"  />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    </uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                </uasp:FRow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            </uasp:FrameWindow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    </tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    <tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        <td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <uasp:ASCXButton ID=\"btnLogin\" IsDefault=\"true\" runat=\"server\" Text=\"<%$ resources:GeneralResource,Caption_Login %>\"");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                OnClick=\"btnLogin_Click\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        <td width=\"100%\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <uasp:ASCXButton ID=\"btnReset\" runat=\"server\" Text=\"<%$ resources:GeneralResource,Caption_Reset %>\"");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                OnClientClick=\"ResetControls()\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    </tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                </table>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            <td width=\"35%\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        </tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    </table>        ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string Login()
{ return Login(string.Empty);}
public static string GeneralUsing(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "/** 
Copyright (c) 2010, Sheikh Abdul Wahid Ahmed
Details @ http://extremecodeworld.codeplex.com/license
**/

using System;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode.BusinessLayer;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode.DataAccessLayer;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode.Utils;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode.Common; ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode.Common.Security;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode.Logging;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Data;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Collections;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Collections.Generic;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Text;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


foreach(string accessorName in RepositoryManager.Instance.Entities.Accessors)
{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(RepositoryManager.Instance.Repository.ProjectName);

codeGeneratorVariable_DisplayCode.Append(".BusinessObjects." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(accessorName);

codeGeneratorVariable_DisplayCode.Append(";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "/** Custom Region Start [Using] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "/** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string GeneralUsing()
{ return GeneralUsing(string.Empty);}
public static string ASPXLoginWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "<%@ Page Language=\"C#\" MasterPageFile=\"~/DefaultMasterPage.master\" AutoEventWireup=\"true\"");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ValidateRequest=\"false\" CodeFile=\"Login.aspx.cs\" Inherits=\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(RepositoryManager.Instance.Repository.ProjectName);

codeGeneratorVariable_DisplayCode.Append(".Login\" %>" + "\r\n" + codeGeneratorVariable_Prefix + "<asp:Content ID=\"Content1\" ContentPlaceHolderID=\"Content\" runat=\"Server\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		codeGeneratorVariable_DisplayCode.Append(Login() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "</asp:Content>	");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string ASPXLoginWholeClass()
{ return ASPXLoginWholeClass(string.Empty);}
public static string ASPXBOEditFrame(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;
		
		
				
		//overriding entity.
		Entity entityBOPage =  RepositoryManager.Instance.Entities["BOPage",entity.Name];
		Entity entityBOEditPage =  RepositoryManager.Instance.Entities["BOEditPage",entity.Name];
		if(entityBOPage != null)
		{
			entityBOPage.OverridingEntity = entityBOEditPage;
		}
		entity.OverridingEntity = entityBOPage;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <uasp:Frame runat=\"server\" ID=\"editFrame\" Title=\"<%$ resources:");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(",EditFrameTitle %>\" Width=\"100%\" >" + "\r\n" + codeGeneratorVariable_Prefix + "        <uasp:FrameHeader>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            <uasp:FCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                <table>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    <tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        <td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <uasp:ASCXButton ID=\"btnBackToList\" runat=\"server\" Text=\"Back\" NavigateUrl=\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("List.aspx\" />" + "\r\n" + codeGeneratorVariable_Prefix + "                        </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    </tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                </table>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            </uasp:FCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        </uasp:FrameHeader>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        <uasp:FRow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            <uasp:FCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            	<asp:ValidationSummary id=\"vldrSummary\" runat=\"server\" HeaderText=\"\"");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    ShowSummary=\"False\" ShowMessageBox=\"True\" ForeColor=\"#FF0000\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "                <asp:MultiView runat=\"server\" ID=\"mvMessage\" ActiveViewIndex=\"1\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    <asp:View runat=\"server\" ID= \"viewError\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        <table width=\"100%\" class=\"tableError\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                <td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    <asp:Label ID=\"lblError\" runat=\"server\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            </tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        </table>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    </asp:View>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    <asp:View runat=\"server\" ID= \"viewInformation\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        <table width=\"100%\" class=\"tableInformation\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                <td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    <asp:Label ID=\"lblInformation\" runat=\"server\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            </tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        </table>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    </asp:View>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    </asp:MultiView>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                <table width=\"100%\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    <tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    <td rowspan=\"2\" width=\"1\">&nbsp;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        <td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <br />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <uasp:FrameWindow runat=\"server\" ID=\"editFrameWindow\" OnInit= \"EditFrameWindow_OnInit\">");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		int fieldIndex=0;
		int pairsCount=entity.FieldsCountInSingleRow;
		bool isConfimationItration = false;
		while(fieldIndex<entity.SortedFields.Count || isUserRoleClass || (isUserLoginClass && !isLoginFeatureIgnored)  )
		{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								<uasp:FRow>");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

	
			int i=0;
			for(; i<pairsCount && fieldIndex<entity.SortedFields.Count;)
			{
				Entity.Field entityField = entity.SortedFields[fieldIndex];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


				if(dataType=="shortbinary" || dataType =="binary" || !displayed)
				{
					//move to next filed but dont increase 'i' pointer 
					fieldIndex++;
					continue;
				}
				else
				{
					//increase 'i' pointer
					i++;
				}
				
				string usedControl = (listTable == string.Empty)? webControl: listControl;
				string suffix = string.Empty;
				string strConfirmation = string.Empty;
				if(entityField.ConfirmationRequired)
				{
					if(isConfimationItration)
					{
						//now it has been consumed.
						fieldIndex++;
						strConfirmation = "Confirmation";
						isConfimationItration = false;
					}
					else
					{
						isConfimationItration = true;
					}
				}
				else
				{
					//it has been consumed.
					fieldIndex++;
				}
				Logger.Write(fieldIndex.ToString(), "generator");
				Logger.Write(entityField.Name, "generator");
				Logger.Write(entityField.ASPXAttributes, "generator");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<%-- Custom Region Start [Fields");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(strConfirmation);

codeGeneratorVariable_DisplayCode.Append("(" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityField.Name);

codeGeneratorVariable_DisplayCode.Append(")] --%>" + "\r\n" + codeGeneratorVariable_Prefix + "									<uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                        <asp:Label ID=\"lbl");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(strConfirmation);

codeGeneratorVariable_DisplayCode.Append("\" runat=\"server\" Text=\"<%$ resources:" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(",Field_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(strConfirmation);

codeGeneratorVariable_DisplayCode.Append(" %>\"/>" + "\r\n" + codeGeneratorVariable_Prefix + "                                    </uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    <uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                        <uasp:");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(usedControl);

codeGeneratorVariable_DisplayCode.Append(" ID=\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(strConfirmation);

codeGeneratorVariable_DisplayCode.Append("\" runat=\"server\" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(strIsDecimalNumberAttb);

codeGeneratorVariable_DisplayCode.Append("  Caption = \"<%$ resources:" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(",Field_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(strConfirmation);

codeGeneratorVariable_DisplayCode.Append(" %>\"  " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityField.ASPXAttributes);

codeGeneratorVariable_DisplayCode.Append("   />" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


                                     if(strConfirmation != string.Empty)
                                     {
codeGeneratorVariable_DisplayCode.Append("   " + "\r\n" + codeGeneratorVariable_Prefix + "                                        <uasp:AWCompareValidator Text=\"*\" ID=\"vldr");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("Confirmation\" runat = \"server\" SetFocusOnError=\"true\" Display=\"Dynamic\" ControlToCompare=\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(strConfirmation);

codeGeneratorVariable_DisplayCode.Append("\" ControlToValidate = \"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("\"></uasp:AWCompareValidator>" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


                                     }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    </uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    <%-- Custom Region End --%>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

	
			}
			if(fieldIndex >= entity.SortedFields.Count && i<pairsCount && (isUserRoleClass || (isUserLoginClass && !isLoginFeatureIgnored ) ) )
			{
				if(isUserLoginClass && !isLoginFeatureIgnored)
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                        <asp:Label ID=\"lblSecurityGroups\" runat=\"server\" Text=\"<%$ resources:GeneralResource,Field_SecurityGroups %>\"/>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    </uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    <uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                        <uasp:ASCXCheckBoxList ID=\"chkListSecurityGroups\" runat=\"server\" Caption = \"<%$ resources:GeneralResource,Field_SecurityGroups %>\"    />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    </uasp:WCell>	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								</uasp:FRow>	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


					break;
				}
				else if(isUserRoleClass)
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                        <asp:Label ID=\"lblSecurityModules\" runat=\"server\" Text=\"<%$ resources:GeneralResource,Field_SecurityModules %>\"/>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    </uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    <uasp:WCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "										<asp:TreeView ID=\"tvSecurityModules\" runat=\"server\" DataSourceID=\"smdsSecurityModules\"");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "											 ShowCheckBoxes=\"All\" ShowLines=\"True\" OnTreeNodeDataBound=\"tvSecurityModules_TreeNodeDataBound\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "										</asp:TreeView>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "										<script>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                            //firfox passing passing event arg. so will have to add script block.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                            document.getElementById('<%= tvSecurityModules.ClientID %>').onclick=InTreeViewCheckAll;										");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "										</script>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "										<asp:SiteMapDataSource ID=\"smdsSecurityModules\" runat=\"server\" SiteMapProvider=\"SMProvderForConfiguring\"");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "										 ShowStartingNode=\"False\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    </uasp:WCell>	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								</uasp:FRow>	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

		
					break;
				} 
			}
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + codeGeneratorVariable_Prefix + "								</uasp:FRow>	");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                             <%-- Custom Region Start [CustomSearchFields] --%>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                             <%-- Custom Region End --%>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            </uasp:FrameWindow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    </tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    <tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        <td >");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <table width=\"1\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                <tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    <td style=\"width: 100px\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                        <uasp:ASCXButton ID=\"btnSave\" IsDefault=\"true\" runat=\"server\" OnClick=\"btnSave_Click\" Text=\"<%$ resources:GeneralResource,Caption_Save %>\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    <td style=\"width: 100px\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                        <uasp:ASCXButton ID=\"btnReset\" runat=\"server\" Text=\"<%$ resources:GeneralResource,Caption_Reset %>\" OnClientClick=\"ResetEditPanel()\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                    </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                </tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            </table>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                            <br />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        </td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    </tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                </table>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            </uasp:FCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        </uasp:FRow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    </uasp:Frame>");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string ASPXBOEditFrame()
{ return ASPXBOEditFrame(string.Empty);}
public static string BUZDateTableMembers(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region Members.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Construtors");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable():base(" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".DATATABLE_NAME){DefineDataTable(this);}" + "\r\n" + codeGeneratorVariable_Prefix + "		internal ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable(DataTable table) : " + "\r\n" + codeGeneratorVariable_Prefix + "                base(table.TableName) {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            if ((table.CaseSensitive != table.DataSet.CaseSensitive)) {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                this.CaseSensitive = table.CaseSensitive;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            if ((table.Locale.ToString() != table.DataSet.Locale.ToString())) {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                this.Locale = table.Locale;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            if ((table.Namespace != table.DataSet.Namespace)) {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                this.Namespace = table.Namespace;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            this.Prefix = table.Prefix;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            this.MinimumCapacity = table.MinimumCapacity;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            this.DisplayExpression = table.DisplayExpression;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Methods");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow New" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow()" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow)this.NewRow();" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		if(keySignature != string.Empty)
		{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow Get" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("ByKey(" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(keySignature);

codeGeneratorVariable_DisplayCode.Append(")" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ArrayList al=new ArrayList();");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" col = " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(".NewInstance;" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			foreach(Entity.Field entityField in entity.PrimaryKey)
			{   

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			al.Add(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldVariable);

codeGeneratorVariable_DisplayCode.Append(");" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return this.Rows.Find(al.ToArray()) as ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow;" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region IEnumerable Implementation");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public System.Collections.IEnumerator GetEnumerator()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            return this.Rows.GetEnumerator();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Overridden Members");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override System.Type GetRowType() ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return typeof(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow);" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override DataRow NewRowFromBuilder(DataRowBuilder builder) ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow(builder);" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Properties");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow this[int index]" + "\r\n" + codeGeneratorVariable_Prefix + "        {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow)this.Rows[index];" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "        #endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZDateTableMembers()
{ return BUZDateTableMembers(string.Empty);}
public static string BOEditWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Configuration;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.Security;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI.WebControls;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI.WebControls.WebParts;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI.HtmlControls;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode.PresentationLayer;	");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;
		
        //overriding entity.
		Entity entityBOPage =  RepositoryManager.Instance.Entities["BOPage",entity.Name];
		Entity entityBOEditPage =  RepositoryManager.Instance.Entities["BOEditPage",entity.Name];
		if(entityBOPage != null)
		{
			entityBOPage.OverridingEntity = entityBOEditPage;
		}
		entity.OverridingEntity = entityBOPage;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


        
		codeGeneratorVariable_DisplayCode.Append(GeneralUsing() + Environment.NewLine);
		string[] editKeyFields = entity.EditKey.Split(',');
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "namespace ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(RepositoryManager.Instance.Repository.ProjectName);

codeGeneratorVariable_DisplayCode.Append(".Aspx." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(accessorName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	public partial class ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Edit : EditParentPage,IEditPage" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        /** Custom Region Start [Main] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        /** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "        public void EditFrameWindow_OnInit(object sender, EventArgs e)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			/** Custom Region Start [EditFrameWindow_OnInit] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			/** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "        protected override void OnPreInit(EventArgs e)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			if (!IsPostBack)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				if (IsUpdate)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					if(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


						string or="";			  
						foreach(string keyField in editKeyFields)
						{
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(or);

codeGeneratorVariable_DisplayCode.Append("string.IsNullOrEmpty(Request.QueryString[" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.ConstantNStatic(keyField));

codeGeneratorVariable_DisplayCode.Append("])" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


							or = " || "; 
						}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						throw Logger.Write(new Exception(\"Edit page requires 'key' for updating.\"));");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "					// initialize key");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					Pair[] key = new Pair[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(editKeyFields.Length);

codeGeneratorVariable_DisplayCode.Append("];" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


						for(int i=0; i<editKeyFields.Length; i++)
						{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					key[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(i);

codeGeneratorVariable_DisplayCode.Append("] = new Pair(" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.ConstantNStatic(editKeyFields[i]));

codeGeneratorVariable_DisplayCode.Append(", Request.QueryString[" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.ConstantNStatic(editKeyFields[i]));

codeGeneratorVariable_DisplayCode.Append("]);" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


						}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					Key = key;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			base.OnPreInit(e);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		protected override void OnLoad(EventArgs e)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "			if (!IsPostBack)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				PopulateListControls();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				RowToControl(BOPaper as ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Paper); " + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			/** Custom Region Start [Page_OnLoad] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "   			/** Custom Region End**/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			base.OnLoad(e);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		 codeGeneratorVariable_DisplayCode.Append(BOEditPopulateListControls() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BOEditControlToRow() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BOEditRowToControl() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


	if(isUserRoleClass)
	{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	protected void tvSecurityModules_TreeNodeDataBound(object sender, TreeNodeEventArgs e)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		SiteMapNode siteMapNode = e.Node.DataItem as SiteMapNode;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		e.Node.Value = siteMapNode.Key;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		if (IsUpdate)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			e.Node.Checked = ((IRole)BO).IsUserAuthorizedForModule(e.Node.Value);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}	");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

	
	}
codeGeneratorVariable_DisplayCode.Append(" " + "\r\n" + codeGeneratorVariable_Prefix + "	#region IEditPage Members");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "	public string EntityName");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		get { return \"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityName);

codeGeneratorVariable_DisplayCode.Append("\"; }" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "	public string ResourceName");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			return \"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	BusinessObjectCollection IPage.BOCollection");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(".Instance;" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "	BusinessObjectPaper IEditPage.GetBOPaper()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		return new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Paper();" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	public MultiView MVMessage");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return mvMessage;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "	#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Event Handlers");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected void btnSave_Click(object sender, EventArgs e)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			/** Custom Region Start [Save] **/");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Paper row = BOPaper as " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Paper;" + "\r\n" + codeGeneratorVariable_Prefix + "			ControlToRow(row);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(" bo = new " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("();" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			if (IsUpdate)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				bo.PopulateObjectForUpdation(row);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			else");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				bo.PopulateObjectForInsertion(row);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			if(isUserLoginClass && !isLoginFeatureIgnored)
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			try");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				bo.Save(true);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				bo.Children_");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(users_rolesClass);

codeGeneratorVariable_DisplayCode.Append(".DeleteRecords(true);" + "\r\n" + codeGeneratorVariable_Prefix + "				foreach(string str in ((string)chkListSecurityGroups.Value).Split(','))");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					if(str == string.Empty) continue;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(users_rolesClass);

codeGeneratorVariable_DisplayCode.Append(" newUsersRoles= bo.CreateNewChild_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(users_rolesClass);

codeGeneratorVariable_DisplayCode.Append("();" + "\r\n" + codeGeneratorVariable_Prefix + "					newUsersRoles[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(users_rolesClass);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.ConstantNStatic(userLogin.roleIdField));

codeGeneratorVariable_DisplayCode.Append("] = str;" + "\r\n" + codeGeneratorVariable_Prefix + "					newUsersRoles.Save(true);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				DataAccessor.CommitTransaction();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			catch(Exception ex)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				DataAccessor.RollbackTransaction();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				throw ex;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

	
			}
			else if(isUserRoleClass)
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			try");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				bo.Save(true);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				bo.Children_");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(roles_modulesClass);

codeGeneratorVariable_DisplayCode.Append(".DeleteRecords(true);" + "\r\n" + codeGeneratorVariable_Prefix + "				foreach(TreeNode node in tvSecurityModules.CheckedNodes)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(roles_modulesClass);

codeGeneratorVariable_DisplayCode.Append(" newRolesModules= bo.CreateNewChild_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(roles_modulesClass);

codeGeneratorVariable_DisplayCode.Append("();" + "\r\n" + codeGeneratorVariable_Prefix + "					newRolesModules[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(roles_modulesClass);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.ConstantNStatic(userRole.moduleIdField));

codeGeneratorVariable_DisplayCode.Append("] = node.Value;" + "\r\n" + codeGeneratorVariable_Prefix + "					newRolesModules.Save(true);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				DataAccessor.CommitTransaction();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			catch(Exception ex)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				DataAccessor.RollbackTransaction();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				throw ex;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			} 	");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

	
			}
			else
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				bo.Save();");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			DoOnSuccessfullSave();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            /** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		private void DoOnSuccessfullSave()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Paper row = BOPaper as " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Paper;" + "\r\n" + codeGeneratorVariable_Prefix + "			string queryString = string.Empty; ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				string seperator = " + \"&\" + ";
				if(gridKey!=string.Empty)
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					queryString =  ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

			  
					string[] strs=gridKey.Split(',');
					for(int i=0;  i<strs.Length; i++)
					{
						string keyField = strs[i];
						if(i == strs.Length-1)
						{
							seperator = ";";
						}
codeGeneratorVariable_DisplayCode.Append("		" + "\r\n" + codeGeneratorVariable_Prefix + "						string.Format(\"{0}={1}\",");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.ConstantNStatic(keyField));

codeGeneratorVariable_DisplayCode.Append("," + "\r\n" + codeGeneratorVariable_Prefix + "							row.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.Property(keyField));

codeGeneratorVariable_DisplayCode.Append(") " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(seperator);

codeGeneratorVariable_DisplayCode.Append("" + "" + "");


						 
					}
					
				}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			Information=ResourceProvider.GetGeneralResourceString(");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                (IsUpdate)? \"Message_RecordUpdatedSuccessfully\":");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    \"Message_RecordAddedSuccessfully\");");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "			Response.Redirect(string.Format(\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Edit.aspx?Update=true&{0}\", queryString), true);" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BOEditWholeClass()
{ return BOEditWholeClass(string.Empty);}
public static string BOEditRowToControl(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;
		
								
		//overriding entity.
		Entity entityBOPage =  RepositoryManager.Instance.Entities["BOPage",entity.Name];
		Entity entityBOEditPage =  RepositoryManager.Instance.Entities["BOEditPage",entity.Name];
		if(entityBOPage != null)
		{
			entityBOPage.OverridingEntity = entityBOEditPage;
		}
		entity.OverridingEntity = entityBOPage;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected void RowToControl(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Paper row)" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


            foreach(string entityFieldKey in entity.Fields.Keys)
            {
                Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


				if(!displayed)
				{
					continue;
				}
				if(dataType == "shortbinary" || dataType == "binary")
				{
					//will handle it later
					continue;
				}
				codeGeneratorVariable_DisplayCode.Append(Environment.NewLine + Environment.NewLine);
				string usedControl = (listTable == string.Empty)? webControl: listControl;
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			//**");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            /** Custom Region Start [RowToControl(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append(")] **/" + "\r\n" + codeGeneratorVariable_Prefix + "			if (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(" != null)" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(".Value = " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(strDecimalCast);

codeGeneratorVariable_DisplayCode.Append(" row." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		    /** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

	
            }
			if(isUserLoginClass && !isLoginFeatureIgnored)
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			if (IsUpdate)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				chkListSecurityGroups.Value = ((");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(")BO).Children_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(users_rolesClass);

codeGeneratorVariable_DisplayCode.Append(".GetFieldValues(" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(users_rolesClass);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.ConstantNStatic(userLogin.roleIdField));

codeGeneratorVariable_DisplayCode.Append("); 	" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

	
			}
			else if(isUserRoleClass)
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			if (IsUpdate)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				foreach (TreeNode node in tvSecurityModules.Nodes)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					node.Checked= ((IRole)BO).IsUserAuthorizedForModule(node.Value);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				} 	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}	");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

	
			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BOEditRowToControl()
{ return BOEditRowToControl(string.Empty);}
public static string DefaultWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Configuration;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.Security;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI.WebControls;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI.WebControls.WebParts;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI.HtmlControls;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode.PresentationLayer;	");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		codeGeneratorVariable_DisplayCode.Append(GeneralUsing() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "namespace ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(RepositoryManager.Instance.Repository.ProjectName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		 codeGeneratorVariable_DisplayCode.Append(DefaultCodeBehind() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string DefaultWholeClass()
{ return DefaultWholeClass(string.Empty);}
public static string TestingOnce(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 

	foreach(string entityKey in RepositoryManager.Instance.Entities.Keys)
	{
		Entity entity=RepositoryManager.Instance.Entities[entityKey]; 

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("			" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string entityFieldKey in entity.Fields.Keys)
		{
			Entity.Field entityField = entity.Fields[entityFieldKey]; 

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);


		}  		
	}
 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string TestingOnce()
{ return TestingOnce(string.Empty);}
public static string BUZDataSetMembers(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "\r\n" + codeGeneratorVariable_Prefix + "        #region Members.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Constructors");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public BODataSet():base(\"BODataSet\"){CreateDataSet(this);}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected BODataSet(SerializationInfo info, StreamingContext context)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			string strSchema = ((string)(info.GetValue(\"XmlSchema\", typeof(string))));");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			if ((strSchema != null))");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				DataSet ds = new DataSet();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				ds.ReadXmlSchema(new XmlTextReader(new System.IO.StringReader(strSchema)));");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				foreach(string key in RepositoryManager.Instance.Entities.Keys)
				{ 
					Entity entity = RepositoryManager.Instance.Entities[key];

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				if ((ds.Tables[\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityName);

codeGeneratorVariable_DisplayCode.Append("\"] != null))" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					this.Tables.Add(new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable(ds.Tables[\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityName);

codeGeneratorVariable_DisplayCode.Append("\"]));" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this.DataSetName = ds.DataSetName;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this.Prefix = ds.Prefix;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this.Namespace = ds.Namespace;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this.Locale = ds.Locale;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this.CaseSensitive = ds.CaseSensitive;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this.EnforceConstraints = ds.EnforceConstraints;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this.Merge(ds, false, System.Data.MissingSchemaAction.Add);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			this.GetSerializationData(info, context);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Methods");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        //**Overridden Members");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Properties");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region DataTables");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string key in RepositoryManager.Instance.Entities.Keys)
		{ 
			Entity entity = RepositoryManager.Instance.Entities[key];

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable Table_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable)this.Tables[\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityName);

codeGeneratorVariable_DisplayCode.Append("\"];" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region Relational Properties");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		#region DataRelations");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string key in RepositoryManager.Instance.Entities.Keys)
		{ 
			Entity entity = RepositoryManager.Instance.Entities[key];
			foreach(string relKey in  entity.Parents.Keys)
			{   
				Entity.Relation relation = entity.Parents[relKey];

string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public DataRelation Relation_");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(parentRelationProperty);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return this.Relations[\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(parentRelationName);

codeGeneratorVariable_DisplayCode.Append("\"];" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}  
		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZDataSetMembers()
{ return BUZDataSetMembers(string.Empty);}
public static string BUZPaperMembers(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region Members.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Construtors");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//For current row");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		internal ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Paper(FieldInfoCollection fields):base(fields){}" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//For new row ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public  ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Paper():base(" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".CreateFieldInfoCollection()){}" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Properties");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string entityFieldKey in entity.Fields.Keys)
		{
			Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


			string strNullable = (isValueType)? "?": string.Empty;
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(strNullable);

codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			if(isValueType)
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				object obj = this[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("];" + "\r\n" + codeGeneratorVariable_Prefix + "				return (obj != null)?");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append("?)Convert.To" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpFrameworkDataType);

codeGeneratorVariable_DisplayCode.Append("(obj):" + "\r\n" + codeGeneratorVariable_Prefix + "					null;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
			else
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				object obj = this[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("];" + "\r\n" + codeGeneratorVariable_Prefix + "				return (obj != null)?");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					obj as ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(":" + "\r\n" + codeGeneratorVariable_Prefix + "					null;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			if(isNative && !tokenEnabled && !autoIncreament )
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("]=value;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public override object this[string fieldName]");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				object obj = base[fieldName];");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return (obj == DBNull.Value || obj ==null)?");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".DEFAULT_VALUES[fieldName]:" + "\r\n" + codeGeneratorVariable_Prefix + "					 obj;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				base[fieldName]= value;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZPaperMembers()
{ return BUZPaperMembers(string.Empty);}
public static string BOEditPopulateListControls(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;
		
				
		//overriding entity.
		Entity entityBOPage =  RepositoryManager.Instance.Entities["BOPage",entity.Name];
		Entity entityBOEditPage =  RepositoryManager.Instance.Entities["BOEditPage",entity.Name];
		if(entityBOPage != null)
		{
			entityBOPage.OverridingEntity = entityBOEditPage;
		}
		entity.OverridingEntity = entityBOPage;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        private void PopulateListControls()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			IListControl ctrl = null;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


        foreach(string entityFieldKey in entity.Fields.Keys)
        {
            Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


            if(listTable != string.Empty)
            {
			codeGeneratorVariable_DisplayCode.Append(Environment.NewLine + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            //**");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            /** Custom Region Start [PopulateListControls(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append(")] **/" + "\r\n" + codeGeneratorVariable_Prefix + "			ctrl = ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[listControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(listTableCollectionName);

codeGeneratorVariable_DisplayCode.Append(" col" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(" = " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(listTableCollectionName);

codeGeneratorVariable_DisplayCode.Append(".Instance;" + "\r\n" + codeGeneratorVariable_Prefix + "			ctrl.Enumerable=col");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "			ctrl.FormatString = \"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(formatString);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n" + codeGeneratorVariable_Prefix + "			ctrl.KeyField = ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(listTableClassName);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(listTableKeyFieldConstant);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "			ctrl.DisplayFieldList = new string[] {");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				string qoma="";			  
                foreach(string displayField in listTableDisplayFields.Split(','))
                {
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(qoma);

codeGeneratorVariable_DisplayCode.Append(listTableClassName);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.ConstantNStatic(displayField));

codeGeneratorVariable_DisplayCode.Append("" + "" + "");


					qoma = ","; 
                }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			};");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ctrl.DataBind();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "           /** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


            }  
        }
		if(isUserLoginClass && !isLoginFeatureIgnored)
		{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ctrl = chkListSecurityGroups;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(roleCollection);

codeGeneratorVariable_DisplayCode.Append(" colSecurityGroups = " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(roleCollection);

codeGeneratorVariable_DisplayCode.Append(".Instance;" + "\r\n" + codeGeneratorVariable_Prefix + "			ctrl.Enumerable=colSecurityGroups;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ctrl.FormatString = \"{0}\";");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ctrl.KeyField = ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(roleClass);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.ConstantNStatic(userRole.roleIdField));

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "			ctrl.DisplayFieldList = new string[] {");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(roleClass);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.ConstantNStatic(userRole.roleNameField));

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			};");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ctrl.DataBind();");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BOEditPopulateListControls()
{ return BOEditPopulateListControls(string.Empty);}
public static string BUZColMembers(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region Members.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Construtors");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//for Default Connection");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append("():base(){}		" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//for Given Connection ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append("(string strConnectionId):base(strConnectionId){}		" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Methods");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public  ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(" CreateNewBusinessObject()" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("(m_da.Name);" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable FillDataTable(DataSet ds)" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable)base.FillDataTable(ds);" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable FillDataTable()" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable)base.FillDataTable();" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Overridden Members");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override void RefreshCache()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".S_RefreshCache();" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override object CreateBusinessObject(FieldInfoCollection fields)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			if(enumeratorReturningPapers)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Paper(fields);" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			else");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("(fields,m_da);" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override FieldInfoCollection GetFieldInfoCollection()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FIELDS;" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override FieldInfoCollection CreateFieldInfoCollection()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".CreateFieldInfoCollection();" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public override BusinessObjectRelationCollection ChildRelations");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".CHILD_RELATIONS;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public override BusinessObjectRelationCollection ParentRelations");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".PARENT_RELATIONS;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public override string View_Name");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".VIEW_NAME;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public override string Table_Name");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".TABLE_NAME;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public override string DataTable_Name");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".DATATABLE_NAME;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override DataTable CreateDataTable()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable();" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "		protected override void PopulateWithCommandCreators(ref CommandCreatorHandler selectCmdCreator,");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ref CommandCreatorHandler updateCmdCreator,");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ref CommandCreatorHandler insertCmdCreator,");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ref CommandCreatorHandler deleteCmdCreator)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//can be used later.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			selectCmdCreator = null; //new CommandCreatorHandler(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".Create_SelectIDbCommand);" + "\r\n" + codeGeneratorVariable_Prefix + "			updateCmdCreator = null; //new CommandCreatorHandler(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".Create_UpdateIDbCommand);" + "\r\n" + codeGeneratorVariable_Prefix + "			insertCmdCreator = null; //new CommandCreatorHandler(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".Create_InsertIDbCommand);" + "\r\n" + codeGeneratorVariable_Prefix + "			deleteCmdCreator = null; //new CommandCreatorHandler(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".Create_DeleteIDbCommand);" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Properties");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public  ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(" BusinessObject" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return base.GetBusinessObject() as ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("; " + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string entityFieldKey in entity.Fields.Keys)
		{
			Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			//binary fields cant be included in where clause. 
			if(dataType!="shortbinary" && dataType!="binary")
			{
				string strNullable = (isValueType)? "?": string.Empty;
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(strNullable);

codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			if(isValueType)
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				object obj = this[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("];" + "\r\n" + codeGeneratorVariable_Prefix + "				return (obj != null)?");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append("?)Convert.To" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpFrameworkDataType);

codeGeneratorVariable_DisplayCode.Append("(obj):" + "\r\n" + codeGeneratorVariable_Prefix + "					null;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
			else
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				object obj = this[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("];" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(" val = (obj != null)?" + "\r\n" + codeGeneratorVariable_Prefix + "					obj as ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(":" + "\r\n" + codeGeneratorVariable_Prefix + "					null;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				if(cSharpKeywordDataType=="string")
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				if(val != null)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					val=val.Trim('%');");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				}			");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return val;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				if(cSharpKeywordDataType=="string")
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				/** Custom Region Start [SetField(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(")] **/" + "\r\n" + codeGeneratorVariable_Prefix + "                value= \"%\" + value.Trim() + \"%\";");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                /** Custom Region End **/				");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("]= value; " + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		}	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				if(isRange)
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(strNullable);

codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_From" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				object obj = this[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append(" + Constants.ColumnSuffix.FROM ];" + "\r\n" + codeGeneratorVariable_Prefix + "				return (obj != null)?");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append("?)Convert.To" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpFrameworkDataType);

codeGeneratorVariable_DisplayCode.Append("(obj):" + "\r\n" + codeGeneratorVariable_Prefix + "					null;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("+Constants.ColumnSuffix.FROM]=value; " + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(strNullable);

codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_To" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				object obj = this[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append(" + Constants.ColumnSuffix.TO ];" + "\r\n" + codeGeneratorVariable_Prefix + "				return (obj != null)?");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append("?)Convert.To" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpFrameworkDataType);

codeGeneratorVariable_DisplayCode.Append("(obj):" + "\r\n" + codeGeneratorVariable_Prefix + "					null;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("+Constants.ColumnSuffix.TO]=value; " + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				}
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		public override object this[string fieldName]");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				string afterTrimed = StringProcessor.RightTrim(fieldName,Constants.ColumnSuffix.TO);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				afterTrimed = StringProcessor.RightTrim(afterTrimed,Constants.ColumnSuffix.TO);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "				object obj = base[fieldName];");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return (obj == null)? ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".DEFAULT_VALUES[afterTrimed]:" + "\r\n" + codeGeneratorVariable_Prefix + "					obj;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				base[fieldName]=value;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZColMembers()
{ return BUZColMembers(string.Empty);}
public static string BOListPopulateBOCollection(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


		
		//overriding entity.
		Entity entityBOPage =  RepositoryManager.Instance.Entities["BOPage",entityName];
		Entity entityBOListSearch =  RepositoryManager.Instance.Entities["BOListSearch",entityName];
		if(entityBOPage != null)
		{
			entityBOPage.OverridingEntity = entityBOListSearch;
		}
		entity.OverridingEntity = entityBOPage;
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        private void PopulateBOCollection()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        {");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" col = GetBOCollectionForList() as " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "            col.Refresh();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            FilterPair.Clear();");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


            foreach(string entityFieldKey in entity.Fields.Keys)
            {
                Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


				string strNullable = (isValueType)? "?": string.Empty;
				codeGeneratorVariable_DisplayCode.Append(Environment.NewLine + Environment.NewLine);
                if(dataType!="shortbinary" && dataType!="binary" && displayed)
                {
					 string usedControl = (listTable == string.Empty)? webControl: listControl;
					 if(!usingRange)
					 {
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//**");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            if (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(".Value != null)" + "\r\n" + codeGeneratorVariable_Prefix + "            {");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


						if(usingTime)
						{
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + codeGeneratorVariable_Prefix + "				DateTime dtFrom = Convert.To");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpFrameworkDataType);

codeGeneratorVariable_DisplayCode.Append("(" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(".Value);" + "\r\n" + codeGeneratorVariable_Prefix + "				DateTime dtTo = dtFrom.AddDays(1).AddMilliseconds(-1);// last millisecond of this day;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				col.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_From = dtFrom;" + "\r\n" + codeGeneratorVariable_Prefix + "				col.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_To = dtTo;" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


						}
						else
						{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				col.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(" = Convert.To" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpFrameworkDataType);

codeGeneratorVariable_DisplayCode.Append("(" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(".Value);" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


						}
codeGeneratorVariable_DisplayCode.Append("  " + "\r\n" + codeGeneratorVariable_Prefix + "				FilterPair.Add(new Pair(lbl");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(".Text, " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(".Text));" + "\r\n" + codeGeneratorVariable_Prefix + "            } ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


					}
					else //user range
					{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//**");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            if (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_From.Value != null)" + "\r\n" + codeGeneratorVariable_Prefix + "            {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            	col.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_From = Convert.To" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpFrameworkDataType);

codeGeneratorVariable_DisplayCode.Append("(" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_From.Value);" + "\r\n" + codeGeneratorVariable_Prefix + "			    FilterPair.Add(new Pair(lbl");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_From.Text, " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_From.Text));" + "\r\n" + codeGeneratorVariable_Prefix + "            } ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			if (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_To.Value != null)" + "\r\n" + codeGeneratorVariable_Prefix + "            {");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


						if(usingTime)
						{
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + codeGeneratorVariable_Prefix + "				DateTime dt = Convert.To");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpFrameworkDataType);

codeGeneratorVariable_DisplayCode.Append("(" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_To.Value);" + "\r\n" + codeGeneratorVariable_Prefix + "				dt = dt.AddDays(1).AddMilliseconds(-1);// last millisecond of this day;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				col.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_To = dt;" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


						}
						else
						{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				col.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_To = Convert.To" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpFrameworkDataType);

codeGeneratorVariable_DisplayCode.Append("(" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_To.Value);" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


						}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			    FilterPair.Add(new Pair(lbl");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_To.Text, " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_To.Text));" + "\r\n" + codeGeneratorVariable_Prefix + "            } ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

					
					}
		    	}  
            }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BOListPopulateBOCollection()
{ return BOListPopulateBOCollection(string.Empty);}
public static string TestingTable(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 

	Entity entity = 
		RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("			" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


	foreach(string entityFieldKey in entity.Fields.Keys)
	{
		Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);


	}
 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string TestingTable()
{ return TestingTable(string.Empty);}
public static string RefEntityFieldIncludes(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 

	/*string refEntityFieldCaption = refEntityField.Caption;
	string refProperty=  StringProcessor.Property(refEntityField.Name);
	string refEntityFieldName=  refEntityField.Name;
	string refEntityFieldConstant = StringProcessor.ConstantNStatic(refEntityField.Name);
	string refDbParameter = StringProcessor.DBParameter(refEntityField.Name);
	string refEntityFieldVariable = StringProcessor.Variable(refEntityField.Name);
	string refTokenId=refEntityField.TokenId;
	bool refAutoIncreament=refEntityField.AutoIncreament;
	bool refTokenEnabled=refEntityField.TokenEnabled;
	bool refIsNative=refEntityField.IsNative;
	bool refIsRange=refEntityField.IsRange;
	bool refIsKey=refEntityField.IsKey;
	bool refIsUnique=refEntityField.IsUnique; 
	string refCSharpKeywordDataType=FreeHash.CSharpType[refEntityField.DataType]; 
	string refDataType=refEntityField.DataType; 
	string refCSharpFrameworkDataType=FreeHash.CSharpSystemType[refEntityField.DataType];*/
 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string RefEntityFieldIncludes()
{ return RefEntityFieldIncludes(string.Empty);}
public static string BUZDateRowMembers(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region Members.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Construtors");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		internal ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow(DataRowBuilder rb) : base(rb){} " + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Methods");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Properties");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string entityFieldKey in entity.Fields.Keys)
		{
			Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


			string strNullable = (isValueType)? "?": string.Empty;
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(strNullable);

codeGeneratorVariable_DisplayCode.Append(" Value_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			if(isValueType)
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				object obj = this[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("];" + "\r\n" + codeGeneratorVariable_Prefix + "				return (obj != null)?");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append("?)Convert.To" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpFrameworkDataType);

codeGeneratorVariable_DisplayCode.Append("(obj):" + "\r\n" + codeGeneratorVariable_Prefix + "					null;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
			else
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				object obj = this[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("];" + "\r\n" + codeGeneratorVariable_Prefix + "				return (obj != null)?");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					obj as ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(":" + "\r\n" + codeGeneratorVariable_Prefix + "					null;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			if(isNative && !tokenEnabled && !autoIncreament )
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("]=value;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region Relational Properties");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region Children");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string relKey in  entity.Children.Keys)
		{   
			Entity.Relation relation = entity.Children[relKey];

string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;


			Entity refEntity = relation.ReferencedEntity;

string refClassName=  StringProcessor.Class(refEntity.Name) + "BO";
    string refCollectionName=  refClassName + "Collection";
	string refEntityName=  refEntity.Name;
	string refEntityCaption = refEntity.Caption;
	string refEntityVariable = StringProcessor.Variable(refEntity.Name);
	string refTableName=refEntity.TableName; 
	string refViewName=refEntity.ViewName;
	string refKeySignature=refEntity.KeySignature;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refEntityName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append("DataRow[] Children_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ((");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append("DataRow[])(base.GetChildRows(this.Table.ChildRelations[\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(childRelationName);

codeGeneratorVariable_DisplayCode.Append("\"])));" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region Parents");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string relKey in  entity.Parents.Keys)
		{   
			Entity.Relation relation = entity.Parents[relKey];

string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;


			Entity refEntity = relation.ReferencedEntity;

string refClassName=  StringProcessor.Class(refEntity.Name) + "BO";
    string refCollectionName=  refClassName + "Collection";
	string refEntityName=  refEntity.Name;
	string refEntityCaption = refEntity.Caption;
	string refEntityVariable = StringProcessor.Variable(refEntity.Name);
	string refTableName=refEntity.TableName; 
	string refViewName=refEntity.ViewName;
	string refKeySignature=refEntity.KeySignature;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refEntityName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append("DataRow Parent_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ((");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append("DataRow)(base.GetParentRow(this.Table.ParentRelations[\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(parentRelationName);

codeGeneratorVariable_DisplayCode.Append("\"])));" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                this.SetParentRow(value, this.Table.ParentRelations[\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(parentRelationName);

codeGeneratorVariable_DisplayCode.Append("\"]);" + "\r\n" + codeGeneratorVariable_Prefix + "            }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "		public object this[string fieldName]");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				object obj= base[fieldName];");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return (obj ==DBNull.Value)?");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".DEFAULT_VALUES[fieldName]:" + "\r\n" + codeGeneratorVariable_Prefix + "					 obj;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				if(value == null)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					value = DBNull.Value;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				base[fieldName]= value;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZDateRowMembers()
{ return BUZDateRowMembers(string.Empty);}
public static string Default(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <asp:SiteMapDataSource ID=\"siteMapDataSource\" runat=\"server\" />    ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <div>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    </div>");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string Default()
{ return Default(string.Empty);}
public static string ASPXBOListResultFrame(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


						
		//overriding entity.
		Entity entityBOPage =  RepositoryManager.Instance.Entities["BOPage",entityName];
		Entity entityBOListGrid =  RepositoryManager.Instance.Entities["BOListGrid",entityName];
		if(entityBOPage != null)
		{
			entityBOPage.OverridingEntity = entityBOListGrid;
		}
		entity.OverridingEntity = entityBOPage;
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	<uasp:Frame runat=\"server\" ID=\"resultFrame\" Title=\"<%$ resources:");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(",ResultFrameTitle %>\" Width=\"100%\" CssClass = \"frameSearchResult\" >" + "\r\n" + codeGeneratorVariable_Prefix + "		<%-- Custom Region Start [ResultFrameHeader] --%>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		<uasp:FrameHeader>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			<uasp:FCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				<table width=\"100\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					<tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						<td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							<uasp:ASCXButton ID=\"btnAddNew\" runat=\"server\" Text=\"<%$ resources:GeneralResource,Caption_AddNew %>\"  NavigateUrl=\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Edit.aspx\" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(newButtonAttributes);

codeGeneratorVariable_DisplayCode.Append(" />" + "\r\n" + codeGeneratorVariable_Prefix + "							<uasp:ASCXButton ID=\"btnRetunRowsKeys\"  runat=\"server\" Text=\"<%$ resources:GeneralResource,Caption_Select %>\" Visible=\"false\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "						</td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					</tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				</table>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			</uasp:FCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		</uasp:FrameHeader>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		<%-- Custom Region End --%>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		<uasp:FRow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			<uasp:FCell VerticalAlign=\"Top\" HorizontalAlign=\"Center\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				<asp:MultiView runat=\"server\" ID=\"mvMessage\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					<asp:View runat=\"server\" ID= \"viewError\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						<table width=\"100%\" class=\"tableError\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							<tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								<td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<asp:Label ID=\"lblError\" runat=\"server\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								</td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							</tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						</table>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					</asp:View>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					<asp:View runat=\"server\" ID= \"viewInformation\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						<table width=\"100%\" class=\"tableInformation\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							<tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								<td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<asp:Label ID=\"lblInformation\" runat=\"server\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								</td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							</tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						</table>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					</asp:View>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				</asp:MultiView>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				<asp:MultiView runat=\"server\" ID=\"mvSearchResult\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					<asp:View runat=\"server\" ID= \"viewRecordsFound\" > ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					<%-- Custom Region Start [GridViewTop] --%>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					<%-- Custom Region End --%>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						<asp:GridView ID=\"gv");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("\" runat=\"server\" CssClass=\"awTable\" OnRowDataBound=\"gv" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("_RowDataBound\"" + "\r\n" + codeGeneratorVariable_Prefix + "							AutoGenerateColumns=\"false\" Width=\"100%\" OnRowCommand=\"gv");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("_RowCommand\" OnRowEditing = \"gv" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("_RowEditing\"" + "\r\n" + codeGeneratorVariable_Prefix + "							OnRowCreated=\"gv");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("_RowCreated\" OnRowDeleting = \"gv" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("_RowDeleting\"  >" + "\r\n" + codeGeneratorVariable_Prefix + "							<HeaderStyle Wrap=\"False\" CssClass=\"awTableHeader\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							<RowStyle CssClass=\"awTableRow\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							<AlternatingRowStyle CssClass=\"awTableAltRow\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							<EditRowStyle CssClass=\"awTableEditRow\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							<FooterStyle CssClass=\"awTableFooter\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							<SelectedRowStyle CssClass=\"awTableSelectRow\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							<Columns>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								<asp:TemplateField>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<ItemStyle Wrap=\"True\" CssClass= \"awTableItemCheckBox\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<HeaderStyle Width=\"1\" CssClass=\"awTableHeaderCheckBox\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<HeaderTemplate>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "										<asp:CheckBox runat=\"server\" ID=\"chkSelectAll\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									</HeaderTemplate>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<ItemTemplate>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "										<asp:CheckBox runat=\"server\" ID=\"chkSelect\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									</ItemTemplate>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								</asp:TemplateField>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								<asp:TemplateField>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<HeaderTemplate>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "										<asp:Label runat=\"server\" ID=\"lblSerialNumCaption\" CssClass=\"awTableHeader\" Text=\"<%$ resources:GeneralResource,Caption_SerialNum %>\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									</HeaderTemplate>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<ItemTemplate>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "										<asp:Label ID=\"lblSerialNum\" runat=\"server\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "										<asp:HiddenField ID = \"hdnSerialNum\" runat =\"server\"  />   ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									</ItemTemplate>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								</asp:TemplateField>");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


            for(int i=0; i<entity.SortedFields.Keys.Count; i++)
            {
				
				Entity.Field entityField = entity.SortedFields[i];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


				if(!displayed)
				{
					continue;
				}
				if(dataType == "shortbinary" || dataType == "binary")
				{
					//will handle it later
					continue;
				}
				string usedControl = (listTable == string.Empty)? webControl: listControl;
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								<asp:TemplateField>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<ItemStyle Wrap=\"True\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<HeaderTemplate>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "										<asp:LinkButton runat='server' ID=\"btn");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("\" CommandName=\"Sort\"" + "\r\n" + codeGeneratorVariable_Prefix + "										CommandArgument=\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append("\" Text = \"<%$ resources:" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(",Field_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(" %>\" CausesValidation=\"false\"  />" + "\r\n" + codeGeneratorVariable_Prefix + "									</HeaderTemplate>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<ItemTemplate>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "										<uasp:");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(usedControl);

codeGeneratorVariable_DisplayCode.Append(" ID=\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("\" runat=\"server\" IsReadOnly=\"true\" DisplayCssClass = \"awGridValue\" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(strUsingTimeAttb);

codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(strIsDecimalNumberAttb);

codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityField.ASPXAttributes);

codeGeneratorVariable_DisplayCode.Append(" />" + "\r\n" + codeGeneratorVariable_Prefix + "									</ItemTemplate>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								</asp:TemplateField>");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

	
			}
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + codeGeneratorVariable_Prefix + "								<%-- Custom Region Start [ActionButtons] --%>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								<asp:TemplateField>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<ItemStyle Wrap=\"True\" Width=\"1\" HorizontalAlign=\"Left\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<HeaderStyle HorizontalAlign=\"Left\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<HeaderTemplate>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "										<asp:Table runat=\"server\" ID=\"tblActions\" CellPadding=\"0\" CellSpacing=\"0\" BorderWidth=\"0\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "											<asp:TableRow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "												<asp:TableCell ID=\"cellDeleteSelected\" Width=\"1\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "													<asp:ImageButton runat=\"server\" ID=\"btnDeleteSelected\" CommandName = \"SelectedAction\" CommandArgument =\"DeleteSelected\"  ImageUrl=\"~/Images/delete.gif\" CausesValidation=\"false\" />    ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "												</asp:TableCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "											</asp:TableRow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "										</asp:Table>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									</HeaderTemplate>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<ItemTemplate>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "										<asp:Table runat=\"server\" ID=\"tblRowActions\"  CellPadding=\"0\" CellSpacing=\"0\" BorderWidth=\"0\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "											<asp:TableRow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "												<asp:TableCell ID=\"cellEdit\" Width=\"1\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "													<asp:ImageButton runat=\"server\" ID=\"btnEdit\" CommandName=\"Edit\" ImageUrl=\"~/Images/edit.gif\" CausesValidation=\"false\" />    ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "												</asp:TableCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "												<asp:TableCell ID=\"cellDelete\" Width=\"1\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "													<asp:ImageButton runat=\"server\" ID=\"btnDelete\" CommandName=\"Delete\" ImageUrl=\"~/Images/delete.gif\" CausesValidation=\"false\" />    ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "												</asp:TableCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "											</asp:TableRow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "										</asp:Table>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									</ItemTemplate>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								</asp:TemplateField>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								<%-- Custom Region End --%>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							</Columns>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						</asp:GridView>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						<uasp:Pager ID=\"pager");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("\" runat=\"server\"></uasp:Pager>" + "\r\n" + codeGeneratorVariable_Prefix + "					</asp:View> ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					<asp:View ID=\"viewNoRecodFound\" runat=\"server\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						<table width=\"100%\" class=\"tableNoRecordFoundMessage\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							<tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								<td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									<asp:Label ID=\"lblNoRecordFoundMessage\" runat=\"server\"");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "									Text=\"<%$ resources:GeneralResource,Message_NoRecordFound %>\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								</td>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							</tr>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						</table>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					</asp:View>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				</asp:MultiView>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			</uasp:FCell>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		</uasp:FRow>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    </uasp:Frame>");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string ASPXBOListResultFrame()
{ return ASPXBOListResultFrame(string.Empty);}
public static string BUZStaticMethods(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region Static Methods");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		internal static FieldInfoCollection  CreateFieldInfoCollection()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			FieldInfoCollection fields=new FieldInfoCollection(DATATABLE_NAME,TABLE_NAME,VIEW_NAME);");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			foreach(string entityFieldKey in entity.Fields.Keys)
			{
				Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


codeGeneratorVariable_DisplayCode.Append("		" + "\r\n" + codeGeneratorVariable_Prefix + "				fields.Add(FieldNames.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("," + "\r\n" + codeGeneratorVariable_Prefix + "					new FieldInfo(FieldNames.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append(",\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(dataType);

codeGeneratorVariable_DisplayCode.Append("\"," + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(isKey.ToString().ToLower());

codeGeneratorVariable_DisplayCode.Append("," + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(isUnique.ToString().ToLower());

codeGeneratorVariable_DisplayCode.Append(",\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(tokenId);

codeGeneratorVariable_DisplayCode.Append("\"," + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(autoIncreament.ToString().ToLower());

codeGeneratorVariable_DisplayCode.Append("," + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(isNative.ToString().ToLower());

codeGeneratorVariable_DisplayCode.Append("," + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(isRange.ToString().ToLower());

codeGeneratorVariable_DisplayCode.Append("));" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + codeGeneratorVariable_Prefix + "			return fields;	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected static BusinessObjectRelationCollection CreateChildRelations()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			if(CHILD_RELATIONS != null) return CHILD_RELATIONS;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			BusinessObjectRelationCollection relations=new BusinessObjectRelationCollection();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			if(entity.Children.Keys.Count > 0)
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			string[] nativeFields,referencedFields;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			foreach(string childrenKey in  entity.Children.Keys)
			{   
				Entity.Relation relation = entity.Children[childrenKey];

string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//Relation [");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(childRelationName);

codeGeneratorVariable_DisplayCode.Append("]" + "\r\n" + codeGeneratorVariable_Prefix + "			nativeFields=new string[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.NativeKey.Length);

codeGeneratorVariable_DisplayCode.Append("];" + "\r\n" + codeGeneratorVariable_Prefix + "            referencedFields=new string[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.NativeKey.Length);

codeGeneratorVariable_DisplayCode.Append("];" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				for(int i=0; i<relation.NativeKey.Length;  i++)
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            nativeFields[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(i);

codeGeneratorVariable_DisplayCode.Append("]=\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.NativeKey[i].Name);

codeGeneratorVariable_DisplayCode.Append("\";referencedFields[" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(i);

codeGeneratorVariable_DisplayCode.Append("]=\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.ReferencedKey[i].Name);

codeGeneratorVariable_DisplayCode.Append("\";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			    }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "            relations.Add(\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.ReferencedEntityName);

codeGeneratorVariable_DisplayCode.Append("\"," + "\r\n" + codeGeneratorVariable_Prefix + "				new BusinessObjectRelation(\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(childRelationName);

codeGeneratorVariable_DisplayCode.Append("\"," + "\r\n" + codeGeneratorVariable_Prefix + "					DATATABLE_NAME,nativeFields,");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    \"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.ReferencedEntityName);

codeGeneratorVariable_DisplayCode.Append("\",referencedFields));" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return relations;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected static BusinessObjectRelationCollection CreateParentRelations()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			if(PARENT_RELATIONS != null) return PARENT_RELATIONS;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			BusinessObjectRelationCollection relations=new BusinessObjectRelationCollection();");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			if(entity.Parents.Keys.Count > 0)
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			string[] nativeFields,referencedFields;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			foreach(string parentsKey in  entity.Parents.Keys)
			{   
				Entity.Relation relation = entity.Parents[parentsKey];

string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				//Relation [");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(parentRelationName);

codeGeneratorVariable_DisplayCode.Append("]" + "\r\n" + codeGeneratorVariable_Prefix + "			    nativeFields=new string[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.NativeKey.Length);

codeGeneratorVariable_DisplayCode.Append("];" + "\r\n" + codeGeneratorVariable_Prefix + "                referencedFields=new string[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.NativeKey.Length);

codeGeneratorVariable_DisplayCode.Append("];" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				for(int i=0; i<relation.NativeKey.Length;  i++)
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                nativeFields[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(i);

codeGeneratorVariable_DisplayCode.Append("]=\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.NativeKey[i].Name);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n" + codeGeneratorVariable_Prefix + "                referencedFields[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(i);

codeGeneratorVariable_DisplayCode.Append("]=\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.ReferencedKey[i].Name);

codeGeneratorVariable_DisplayCode.Append("\";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			    }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                relations.Add(\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.ReferencedEntityName);

codeGeneratorVariable_DisplayCode.Append("\"," + "\r\n" + codeGeneratorVariable_Prefix + "                    new BusinessObjectRelation(\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(parentRelationName);

codeGeneratorVariable_DisplayCode.Append("\"," + "\r\n" + codeGeneratorVariable_Prefix + "                        DATATABLE_NAME,nativeFields,");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        \"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.ReferencedEntityName);

codeGeneratorVariable_DisplayCode.Append("\",referencedFields));" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return relations;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		if(keySignature != string.Empty)
		{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(" Get" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("ByKey(" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(keySignature);

codeGeneratorVariable_DisplayCode.Append(")" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" col = " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(".NewInstance;" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			foreach(Entity.Field entityField in entity.PrimaryKey)
			{   

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			col.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("=" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldVariable);

codeGeneratorVariable_DisplayCode.Append(";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return col.BusinessObject;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		public static  ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(" CreateNewBusinessObject()" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(".Instance.CreateNewBusinessObject(); " + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZStaticMethods()
{ return BUZStaticMethods(string.Empty);}
public static string BUZMembers(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region Members.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Construtors");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//For current row");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		internal ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("(FieldInfoCollection fields ,DataAccessor da):base(fields,da){}" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//For new row with default connection ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public  ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("():base(CONNECTION_ID){}" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//For new row with given connection ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("(string strConnectionId):base(strConnectionId){}" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Methods");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Overridden Members");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override void RefreshCache()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			S_RefreshCache();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override FieldInfoCollection GetFieldInfoCollection()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return FIELDS;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override BusinessObjectRelationCollection ChildRelations");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return CHILD_RELATIONS;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override BusinessObjectRelationCollection ParentRelations");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return PARENT_RELATIONS;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override string Table_Name");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return TABLE_NAME;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override string View_Name");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return VIEW_NAME;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override string DataTable_Name");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".DATATABLE_NAME;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override void PopulateWithCommandCreators(ref CommandCreatorHandler selectCmdCreator,");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ref CommandCreatorHandler updateCmdCreator,");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ref CommandCreatorHandler insertCmdCreator,");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ref CommandCreatorHandler deleteCmdCreator)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//can be used later.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			selectCmdCreator = null; //new CommandCreatorHandler(Create_SelectIDbCommand);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			updateCmdCreator = null; //new CommandCreatorHandler(Create_UpdateIDbCommand);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			insertCmdCreator = null; //new CommandCreatorHandler(Create_InsertIDbCommand);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			deleteCmdCreator = null; //new CommandCreatorHandler(Create_DeleteIDbCommand);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Properties");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string entityFieldKey in entity.Fields.Keys)
		{
			Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


			string strNullable = (isValueType)? "?": string.Empty;
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(strNullable);

codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			if(isValueType)
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				object obj = this[FieldNames.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("];" + "\r\n" + codeGeneratorVariable_Prefix + "				return (obj != null)?");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append("?)Convert.To" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpFrameworkDataType);

codeGeneratorVariable_DisplayCode.Append("(obj):" + "\r\n" + codeGeneratorVariable_Prefix + "					null;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
			else
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				object obj = this[FieldNames.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("];" + "\r\n" + codeGeneratorVariable_Prefix + "				return (obj != null)?");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					obj as ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(":" + "\r\n" + codeGeneratorVariable_Prefix + "					null;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			if(isNative && !tokenEnabled && !autoIncreament )
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this[FieldNames.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("]= value;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region Relational Properties");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region Children");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string relKey in  entity.Children.Keys)
		{   
			Entity.Relation relation = entity.Children[relKey];

string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;


			Entity refEntity = relation.ReferencedEntity;

string refClassName=  StringProcessor.Class(refEntity.Name) + "BO";
    string refCollectionName=  refClassName + "Collection";
	string refEntityName=  refEntity.Name;
	string refEntityCaption = refEntity.Caption;
	string refEntityVariable = StringProcessor.Variable(refEntity.Name);
	string refTableName=refEntity.TableName; 
	string refViewName=refEntity.ViewName;
	string refKeySignature=refEntity.KeySignature;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refEntityName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refCollectionName);

codeGeneratorVariable_DisplayCode.Append(" Children_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refCollectionName);

codeGeneratorVariable_DisplayCode.Append(" colRef=" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refCollectionName);

codeGeneratorVariable_DisplayCode.Append(".Instance;" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			for(int i=0; i<relation.NativeKey.Length;  i++)
			{
				Entity.Field entityField = relation.NativeKey[i];
				Entity.Field refEntityField = relation.ReferencedKey[i];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";



string refEntityFieldCaption = refEntityField.Caption;
	string refProperty=  StringProcessor.Property(refEntityField.Name);
	string refEntityFieldName=  refEntityField.Name;
	string refEntityFieldConstant = StringProcessor.ConstantNStatic(refEntityField.Name);
	string refDbParameter = StringProcessor.DBParameter(refEntityField.Name);
	string refEntityFieldVariable = StringProcessor.Variable(refEntityField.Name);
	string refTokenId=refEntityField.TokenId;
	bool refAutoIncreament=refEntityField.AutoIncreament;
	bool refTokenEnabled=refEntityField.TokenEnabled;
	bool refIsNative=refEntityField.IsNative;
	bool refIsRange=refEntityField.IsRange;
	bool refIsKey=refEntityField.IsKey;
	bool refIsUnique=refEntityField.IsUnique; 
	string refCSharpKeywordDataType=FreeHash.CSharpType[refEntityField.DataType]; 
	string refDataType=refEntityField.DataType; 
	string refCSharpFrameworkDataType=FreeHash.CSharpSystemType[refEntityField.DataType];


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				colRef.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refProperty);

codeGeneratorVariable_DisplayCode.Append("=" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return colRef;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "   		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append(" CreateNewChild_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append("()" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append(" boNew=" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append(".CreateNewBusinessObject();" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			for(int i=0; i<relation.NativeKey.Length;  i++)
			{
				Entity.Field entityField = relation.NativeKey[i];
				Entity.Field refEntityField = relation.ReferencedKey[i];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";



string refEntityFieldCaption = refEntityField.Caption;
	string refProperty=  StringProcessor.Property(refEntityField.Name);
	string refEntityFieldName=  refEntityField.Name;
	string refEntityFieldConstant = StringProcessor.ConstantNStatic(refEntityField.Name);
	string refDbParameter = StringProcessor.DBParameter(refEntityField.Name);
	string refEntityFieldVariable = StringProcessor.Variable(refEntityField.Name);
	string refTokenId=refEntityField.TokenId;
	bool refAutoIncreament=refEntityField.AutoIncreament;
	bool refTokenEnabled=refEntityField.TokenEnabled;
	bool refIsNative=refEntityField.IsNative;
	bool refIsRange=refEntityField.IsRange;
	bool refIsKey=refEntityField.IsKey;
	bool refIsUnique=refEntityField.IsUnique; 
	string refCSharpKeywordDataType=FreeHash.CSharpType[refEntityField.DataType]; 
	string refDataType=refEntityField.DataType; 
	string refCSharpFrameworkDataType=FreeHash.CSharpSystemType[refEntityField.DataType];


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			boNew.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refProperty);

codeGeneratorVariable_DisplayCode.Append("=" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return boNew;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region Parents");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string relKey in  entity.Parents.Keys)
		{   
			Entity.Relation relation = entity.Parents[relKey];

string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;


			Entity refEntity = relation.ReferencedEntity;

string refClassName=  StringProcessor.Class(refEntity.Name) + "BO";
    string refCollectionName=  refClassName + "Collection";
	string refEntityName=  refEntity.Name;
	string refEntityCaption = refEntity.Caption;
	string refEntityVariable = StringProcessor.Variable(refEntity.Name);
	string refTableName=refEntity.TableName; 
	string refViewName=refEntity.ViewName;
	string refKeySignature=refEntity.KeySignature;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refEntityName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append(" Parent_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refCollectionName);

codeGeneratorVariable_DisplayCode.Append(" colRef=" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refCollectionName);

codeGeneratorVariable_DisplayCode.Append(".Instance;" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			for(int i=0; i<relation.NativeKey.Length;  i++)
			{
				Entity.Field entityField = relation.NativeKey[i];
				Entity.Field refEntityField = relation.ReferencedKey[i];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";



string refEntityFieldCaption = refEntityField.Caption;
	string refProperty=  StringProcessor.Property(refEntityField.Name);
	string refEntityFieldName=  refEntityField.Name;
	string refEntityFieldConstant = StringProcessor.ConstantNStatic(refEntityField.Name);
	string refDbParameter = StringProcessor.DBParameter(refEntityField.Name);
	string refEntityFieldVariable = StringProcessor.Variable(refEntityField.Name);
	string refTokenId=refEntityField.TokenId;
	bool refAutoIncreament=refEntityField.AutoIncreament;
	bool refTokenEnabled=refEntityField.TokenEnabled;
	bool refIsNative=refEntityField.IsNative;
	bool refIsRange=refEntityField.IsRange;
	bool refIsKey=refEntityField.IsKey;
	bool refIsUnique=refEntityField.IsUnique; 
	string refCSharpKeywordDataType=FreeHash.CSharpType[refEntityField.DataType]; 
	string refDataType=refEntityField.DataType; 
	string refCSharpFrameworkDataType=FreeHash.CSharpSystemType[refEntityField.DataType];


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				colRef.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refProperty);

codeGeneratorVariable_DisplayCode.Append("=" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return colRef.BusinessObject;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		public override object this[string fieldName]");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				object obj = base[fieldName];");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return (obj == DBNull.Value || obj == null)?");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".DEFAULT_VALUES[fieldName]:" + "\r\n" + codeGeneratorVariable_Prefix + "					 obj;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				base[fieldName]= value;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZMembers()
{ return BUZMembers(string.Empty);}
public static string LoginWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Configuration;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.Security;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI.WebControls;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI.WebControls.WebParts;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI.HtmlControls;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode.PresentationLayer;	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode.Common.UI;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode.Common;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		codeGeneratorVariable_DisplayCode.Append(GeneralUsing() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "namespace ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(RepositoryManager.Instance.Repository.ProjectName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		 codeGeneratorVariable_DisplayCode.Append(LoginCodeBehind() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string LoginWholeClass()
{ return LoginWholeClass(string.Empty);}
public static string ASPXDefaultWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "<%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeFile=\"Default.aspx.cs\" Inherits=\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(RepositoryManager.Instance.Repository.ProjectName);

codeGeneratorVariable_DisplayCode.Append(".Default\" %>" + "\r\n" + codeGeneratorVariable_Prefix + "<html xmlns=\"http://www.w3.org/1999/xhtml\" >");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "<head runat=\"server\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <title>Untitled Page</title>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "</head>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "<body>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <form id=\"form1\" runat=\"server\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		codeGeneratorVariable_DisplayCode.Append(Default() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    </form>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "</body>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "</html>        ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string ASPXDefaultWholeClass()
{ return ASPXDefaultWholeClass(string.Empty);}
public static string BUZDataSetWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Runtime.Serialization;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Xml; ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


codeGeneratorVariable_DisplayCode.Append(GeneralUsing() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "namespace ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(RepositoryManager.Instance.Repository.ProjectName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	[Serializable()]");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	public class BODataSet : BODataSetParent");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		 codeGeneratorVariable_DisplayCode.Append(BUZDataSetInnerClasses() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZDataSetMembers() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZDataSetStaticMetods() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZDataSetWholeClass()
{ return BUZDataSetWholeClass(string.Empty);}
public static string BUZStatics(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region Bussiness Object Statics");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		internal readonly static FieldInfoCollection FIELDS=CreateFieldInfoCollection();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		internal readonly static BusinessObjectRelationCollection CHILD_RELATIONS=CreateChildRelations();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		internal readonly static BusinessObjectRelationCollection PARENT_RELATIONS=CreateParentRelations();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		internal readonly static Hashtable DEFAULT_VALUES=PopulateHashtableWithDefaultValues();	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public class FieldNames");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{	");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


        foreach(string entityFieldKey in entity.Fields.Keys)
        {
            Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            public const string ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append(" = \"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append("\";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


        }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        public static ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" Collection" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(".Instance;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" NewCollection" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(".NewInstance;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZStatics()
{ return BUZStatics(string.Empty);}
public static string UserProfile(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	public class UserProfile : IUserProfile");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		private UserProfile(){}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static UserProfile Instance");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				UserProfile instance = SessionRepository.Instance.UserProfile as UserProfile;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				if (instance == null)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					instance = new UserProfile();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					lock (instance)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						SessionRepository.Instance.UserProfile = instance;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return instance;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static void Initialize()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			UserProfile urserProfile = Instance;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			//initialize here.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		#region IUserProfile Members");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		IDecorator decorator = null;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public IDecorator Decorator");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				if (decorator == null)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					//default decorator");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					decorator = new RSPDecorator();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return decorator;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				decorator = value;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		private IUser user;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public  IUser User");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				if (user == null)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					//default user");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return user;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				user = value;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string UserProfile()
{ return UserProfile(string.Empty);}
public static string BUZColWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


		codeGeneratorVariable_DisplayCode.Append(GeneralUsing() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "namespace ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(RepositoryManager.Instance.Repository.ProjectName);

codeGeneratorVariable_DisplayCode.Append(".BusinessObjects." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(accessorName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	public class ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(":BusinessObjectCollection" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(iUserLoginImplement);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//Thread based Singleton");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		private static ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" singleton;" + "\r\n" + codeGeneratorVariable_Prefix + "		public static ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" Instance" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{	");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" col=null;" + "\r\n" + codeGeneratorVariable_Prefix + "				if(System.Web.HttpContext.Current != null)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					col= System.Web.HttpContext.Current.Session[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".DATATABLE_NAME] as " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				else");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					col=singleton;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "				if(col == null) ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					col=NewInstance;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					if(System.Web.HttpContext.Current != null)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						System.Web.HttpContext.Current.Session[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".DATATABLE_NAME]=col;" + "\r\n" + codeGeneratorVariable_Prefix + "					}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					else");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						singleton = col;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return col;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" NewInstance" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" instence;" + "\r\n" + codeGeneratorVariable_Prefix + "				if(s_connectionId!=\"\") ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    instence=new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append("(s_connectionId);" + "\r\n" + codeGeneratorVariable_Prefix + "				else");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					instence=new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append("();	" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return instence;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		 codeGeneratorVariable_DisplayCode.Append(BUZColMembers() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZColCustomCode() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		if(isUserLoginClass)
		{
codeGeneratorVariable_DisplayCode.Append(" " + "\r\n" + codeGeneratorVariable_Prefix + "		#region IUserLogin Members");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "        public IUser AuthenticateUser(string userId, string password)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            if (!AutoRefresh)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                throw new Exception(\"AuthenticateUser method requires object, to be set 'AutoRefresh'\");");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            this.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.Property(userLogin.UserIdField));

codeGeneratorVariable_DisplayCode.Append(" = userId;" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(userClass);

codeGeneratorVariable_DisplayCode.Append(" bo=GetBusinessObject() as " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(userClass);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "            if (bo == null)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                //authentication failed");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                return null;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            else");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                //match password");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                if ((string.IsNullOrEmpty(bo.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.Property(userLogin.PasswordField));

codeGeneratorVariable_DisplayCode.Append(") && password == userId + \"123\") || " + "\r\n" + codeGeneratorVariable_Prefix + "					DataEncryptor.Instance.GetDecryptedString(bo.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.Property(userLogin.PasswordField));

codeGeneratorVariable_DisplayCode.Append(").Equals(password))" + "\r\n" + codeGeneratorVariable_Prefix + "                {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    //authentication succeeded.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					if (string.IsNullOrEmpty(bo.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.Property(userLogin.PasswordField));

codeGeneratorVariable_DisplayCode.Append("))" + "\r\n" + codeGeneratorVariable_Prefix + "                    {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        //no password has been assigned, need to assign default password.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        bo.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.Property(userLogin.PasswordField));

codeGeneratorVariable_DisplayCode.Append(" = DataEncryptor.Instance.GetEncryptedString(userId);" + "\r\n" + codeGeneratorVariable_Prefix + "                        bo.Save();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    return bo as IUser;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                else");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    //authentication failed");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    return null;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "        #endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append(" " + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZColWholeClass()
{ return BUZColWholeClass(string.Empty);}
public static string BUZWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


		codeGeneratorVariable_DisplayCode.Append(GeneralUsing() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "namespace ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(RepositoryManager.Instance.Repository.ProjectName);

codeGeneratorVariable_DisplayCode.Append(".BusinessObjects." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(accessorName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	public class ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(":BusinessObject" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(iUserImplement);

codeGeneratorVariable_DisplayCode.Append(iRoleImplement);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		 codeGeneratorVariable_DisplayCode.Append(BUZStatics() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZMembers() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZStaticMethods() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZCustomCode() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZDataTableRelatedMethods() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		if(isUserLoginClass)
		{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region IUser Members");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        /** Custom Region Start [UserLogin] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		bool IUser.ChangePassword(string currentPassword, string newPassword)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			if (!string.IsNullOrEmpty(currentPassword))");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				//need to validate current password");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				if (!DataEncryptor.Instance.GetDecryptedString(this.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.Property(userLogin.PasswordField));

codeGeneratorVariable_DisplayCode.Append(").Equals(currentPassword))" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					//validation faied.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					return false;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//now change password.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			this.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.Property(userLogin.PasswordField));

codeGeneratorVariable_DisplayCode.Append(" = DataEncryptor.Instance.GetEncryptedString(newPassword);" + "\r\n" + codeGeneratorVariable_Prefix + "			this.Save();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return true;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "		private IRole defaultRole = null;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		IRole IUser.DefaultRole");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				string defaultRoleId="string.Empty";
				string breakAfterFirstItration="break";
				if(userLogin.DefaultRoleIdField!=string.Empty)
				{
					defaultRoleId= string.Format("Convert.ToString(this.{0})",
						StringProcessor.Property(userLogin.DefaultRoleIdField));
					breakAfterFirstItration = string.Empty;	
				}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				if (defaultRole == null)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					string defaultRoleId = ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(defaultRoleId);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "					bool firstRole = true;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					foreach (IRole role in ((IUser)this).Roles)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						if (firstRole)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							//first role is considered default if 'DefaultRole' is not defined.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							defaultRole = role;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							firstRole = false;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							if(string.IsNullOrEmpty(defaultRoleId))");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								break;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						if (role.RoleId.Equals(defaultRoleId))");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							//defautl role if is defined.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							defaultRole = role;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							break;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return defaultRole;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		bool IUser.IsUserAuthorizedForModule(string key)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			foreach (IRole role in ((IUser)this).Roles)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				if (role.IsUserAuthorizedForModule(key))");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					return true;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return false;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		private IRole[] roles; ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		IRole[] IUser.Roles");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				if (roles == null)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					List<IRole> lRoles = new List<IRole>();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					foreach (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(users_rolesClass);

codeGeneratorVariable_DisplayCode.Append(" userRole in Children_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(users_rolesClass);

codeGeneratorVariable_DisplayCode.Append(".GetBusinessObjects())" + "\r\n" + codeGeneratorVariable_Prefix + "					{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						IRole role = userRole.Parent_");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(roleClass);

codeGeneratorVariable_DisplayCode.Append("; " + "\r\n" + codeGeneratorVariable_Prefix + "						lRoles.Add(role);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					roles = lRoles.ToArray();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return roles;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		string IUser.UserName");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return this.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.Property(userLogin.UserNameField));

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		string IUser.UserId");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return  Convert.ToString(this.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.Property(userLogin.UserIdField));

codeGeneratorVariable_DisplayCode.Append(");" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "        /** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
		else if (isUserRoleClass)
		{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region IRole Members");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        /** Custom Region Start [UserRole] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		string IRole.HomeModule");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				if (userRole.homeModuleIdField != string.Empty)
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return Convert.ToString(this.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.Property(userRole.homeModuleIdField));

codeGeneratorVariable_DisplayCode.Append("); " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				}
				else
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return string.Empty; ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		private Dictionary<string, string> modules;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		bool IRole.IsUserAuthorizedForModule(string key)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			if (modules == null)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				modules=new Dictionary<string,string>();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				foreach (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(roles_modulesClass);

codeGeneratorVariable_DisplayCode.Append("Paper relatedModule in this.Children_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(roles_modulesClass);

codeGeneratorVariable_DisplayCode.Append(".GetBOPapers())" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					string strModule = Convert.ToString(relatedModule.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.Property(userRole.moduleIdField));

codeGeneratorVariable_DisplayCode.Append(");" + "\r\n" + codeGeneratorVariable_Prefix + "					modules.Add(strModule, strModule);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			return modules.ContainsKey(key);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		string IRole.RoleName");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return this.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.Property(userRole.roleNameField));

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		string IRole.RoleId");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return Convert.ToString(this.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.Property(userRole.roleIdField));

codeGeneratorVariable_DisplayCode.Append(");" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        /** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "	public class ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Paper:BusinessObjectPaper" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			codeGeneratorVariable_DisplayCode.Append(BUZPaperMembers() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZWholeClass()
{ return BUZWholeClass(string.Empty);}
public static string RelationIncludes(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 

	/*string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;

	*/
 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string RelationIncludes()
{ return RelationIncludes(string.Empty);}
public static string BOCommonStaticMetods(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region Static Methods");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static Hashtable GetBOTypes()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			if (s_htBOTypes != null)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return s_htBOTypes; ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			s_htBOTypes = new CaseInsensitiveHashtable();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			Hashtable ht=s_htBOTypes;			");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			foreach(string key in RepositoryManager.Instance.Entities.Keys)
			{ 
				Entity entity = RepositoryManager.Instance.Entities[key];

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ht.Add(\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityName);

codeGeneratorVariable_DisplayCode.Append("\",typeof(" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("));" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return ht;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

		
			Repository.Security securityRelated=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
			if(securityRelated != null)
			{
				string userClass = StringProcessor.Class(securityRelated.UserLoginInfo.Entity) + "BO";
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static IUserLogin GetUserLogin()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(userClass);

codeGeneratorVariable_DisplayCode.Append(".Collection; " + "\r\n" + codeGeneratorVariable_Prefix + "		}		");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BOCommonStaticMetods()
{ return BOCommonStaticMetods(string.Empty);}
public static string ASPXBOEditJaveScript(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;
		
				
		//overriding entity.
		Entity entityBOPage =  RepositoryManager.Instance.Entities["BOPage",entity.Name];
		Entity entityBOEditPage =  RepositoryManager.Instance.Entities["BOEditPage",entity.Name];
		if(entityBOPage != null)
		{
			entityBOPage.OverridingEntity = entityBOEditPage;
		}
		entity.OverridingEntity = entityBOPage;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		<%--Jave Script--%>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		<script type=\"text/javascript\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			function ResetEditPanel()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


        foreach(string entityFieldKey in entity.Fields.Keys)
        {
            Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


			if(!displayed)
			{
				continue;
			}
			if(dataType == "shortbinary" || dataType == "binary")
			{
				//will handle it later
				continue;
			}
			string usedControl = (listTable == string.Empty)? webControl: listControl;
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				<%= ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(".ClientID%>.ResetValue();" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			if(entityField.ConfirmationRequired)
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				<%= ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("Confirmation.ClientID%>.ResetValue();" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

	
			}
        }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		</script>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		<%-- Custom Region Start [JavaScript] --%>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		<script type=\"text/javascript\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		</script>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		<%-- Custom Region End --%>");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string ASPXBOEditJaveScript()
{ return ASPXBOEditJaveScript(string.Empty);}
public static string ASPXBOListWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "<%@ Page Language=\"C#\" MasterPageFile=\"~/DefaultMasterPage.master\" AutoEventWireup=\"true\"");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ValidateRequest=\"false\" CodeFile=\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("List.aspx.cs\" Inherits=\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(RepositoryManager.Instance.Repository.ProjectName);

codeGeneratorVariable_DisplayCode.Append(".Aspx." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(accessorName);

codeGeneratorVariable_DisplayCode.Append("." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("List\" %>" + "\r\n" + codeGeneratorVariable_Prefix + "<asp:Content ID=\"Content1\" ContentPlaceHolderID=\"Content\" runat=\"Server\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		codeGeneratorVariable_DisplayCode.Append(ASPXBOListJaveScript() + Environment.NewLine);
		codeGeneratorVariable_DisplayCode.Append(ASPXBOListSearchFrame() + Environment.NewLine);
		codeGeneratorVariable_DisplayCode.Append(ASPXBOListResultFrame() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "</asp:Content>	");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string ASPXBOListWholeClass()
{ return ASPXBOListWholeClass(string.Empty);}
public static string BUZColCustomCode(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//user code should be written under the following region, otherwise code will not be safe.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		/** Custom Region Start [Code Generator] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//Connection Id");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		private static string s_connectionId=\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(accessorName);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n" + codeGeneratorVariable_Prefix + "		/** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZColCustomCode()
{ return BUZColCustomCode(string.Empty);}
public static string BUZDataTableStaticMethods(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region Static Methods");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		private static void DefineDataTable(DataTable dt)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//attach values, will be used by cache logic.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			dt.ExtendedProperties.Add(Constants.NEED_TO_REFRESH,true);  ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			dt.ExtendedProperties.Add(Constants.CONNECTION_ID,");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".CONNECTION_ID);" + "\r\n" + codeGeneratorVariable_Prefix + "			dt.ExtendedProperties.Add(Constants.VIEW_NAME,");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".VIEW_NAME);" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "			DataColumn dc=null;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ArrayList alPK=new ArrayList();");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string entityFieldKey in entity.Fields.Keys)
		{
			Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			/*** ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append("***/ " + "\r\n" + codeGeneratorVariable_Prefix + "			dc=dt.Columns.Add(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("," + "\r\n" + codeGeneratorVariable_Prefix + "				typeof(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append("));" + "\r\n" + codeGeneratorVariable_Prefix + "			dc.Unique=");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(isUnique.ToString().ToLower());

codeGeneratorVariable_DisplayCode.Append(";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			if(autoIncreament)
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//value is computed by database management system.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			dc.ReadOnly=true;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			dc.AutoIncrement=true;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			dc.AutoIncrementSeed=-10;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			dc.AutoIncrementStep=-1;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
			
		}
		if(entity.PrimaryKey.Length>0)
		{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			/***PRIMARY KEY***/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			DataColumn[] pk=new DataColumn[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entity.PrimaryKey.Length);

codeGeneratorVariable_DisplayCode.Append("];" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			for(int i=0; i<entity.PrimaryKey.Length;  i++)
			{
				Entity.Field entityField = entity.PrimaryKey[i];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + codeGeneratorVariable_Prefix + "			pk[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(i);

codeGeneratorVariable_DisplayCode.Append("]=dt.Columns[" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("];" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			dt.PrimaryKey=pk;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZDataTableStaticMethods()
{ return BUZDataTableStaticMethods(string.Empty);}
public static string UserProfileWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Configuration;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.Security;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI.WebControls;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI.WebControls.WebParts;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI.HtmlControls;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode.PresentationLayer;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode.Common.UI;	");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		codeGeneratorVariable_DisplayCode.Append(GeneralUsing() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "namespace ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(RepositoryManager.Instance.Repository.ProjectName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		 codeGeneratorVariable_DisplayCode.Append(UserProfile() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string UserProfileWholeClass()
{ return UserProfileWholeClass(string.Empty);}
public static string BUZDataTableRelatedMethods(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region DataTable Related Methods.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable GetDataTable(DataSet ds)" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable)ds.Tables[DATATABLE_NAME];" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable FillDataTable(DataSet ds)" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return Collection.FillDataTable(ds);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable FillDataTable()" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return Collection.FillDataTable();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static void UpdateDataTable(DataTable dt)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			Collection.UpdateDataTable(dt,false);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static void UpdateDataTable(DataTable dt,bool bTransationBased)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			Collection.UpdateDataTable(dt,bTransationBased);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZDataTableRelatedMethods()
{ return BUZDataTableRelatedMethods(string.Empty);}
public static string ASPXBOListJaveScript(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


				
		//overriding entity.
		Entity entityBOPage =  RepositoryManager.Instance.Entities["BOPage",entityName];
		Entity entityBOListSearch =  RepositoryManager.Instance.Entities["BOListSearch",entityName];
		if(entityBOPage != null)
		{
			entityBOPage.OverridingEntity = entityBOListSearch;
		}
		entity.OverridingEntity = entityBOPage;
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		<%--Jave Script--%>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		<script type=\"text/javascript\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			function ResetSearchPanel()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


        foreach(string entityFieldKey in entity.Fields.Keys)
        {
            Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


			if(!displayed)
			{
				continue;
			}
			if(dataType == "shortbinary" || dataType == "binary")
			{
				//will handle it later
				continue;
			}
			string usedControl = (listTable == string.Empty)? webControl: listControl;
			if(!usingRange)
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				<%= ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(".ClientID%>.ResetValue();" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
			else
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				<%= ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_From.ClientID%>.ResetValue();" + "\r\n" + codeGeneratorVariable_Prefix + "				<%= ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_To.ClientID%>.ResetValue();" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

	
			}	
        }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		</script>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		<%-- Custom Region Start [JavaScript] --%>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		<script type=\"text/javascript\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		</script>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		<%-- Custom Region End --%>");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string ASPXBOListJaveScript()
{ return ASPXBOListJaveScript(string.Empty);}
public static string EntityFieldIncludes(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 

	/*string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";




	*/
 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string EntityFieldIncludes()
{ return EntityFieldIncludes(string.Empty);}
public static string BUZCustomCode(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//user code should be written under the following region, otherwise code will not be safe.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		/** Custom Region Start [Code Generator] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public const string VIEW_NAME=\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(viewName);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n" + codeGeneratorVariable_Prefix + "		public const string TABLE_NAME=\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(tableName);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n" + codeGeneratorVariable_Prefix + "		public const string DATATABLE_NAME=\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityName);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n" + codeGeneratorVariable_Prefix + "		public const string CONNECTION_ID=\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(accessorName);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n" + codeGeneratorVariable_Prefix + "		internal static void S_RefreshCache()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			if(CacheRepository.Instance.CachedDataSet != null)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				CacheRepository.Instance.CachedDataSet.Refresh(DATATABLE_NAME); ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		private static Hashtable PopulateHashtableWithDefaultValues()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			Hashtable ht = new Hashtable();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			object val=null;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			foreach(string entityFieldKey in entity.Fields.Keys)
			{
				Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


codeGeneratorVariable_DisplayCode.Append("		" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//**");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				if(cSharpKeywordDataType=="bool")
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			val=null;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				}
				else if(isValueType)
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			val=null;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				}
				else
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			val=null;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ht.Add(FieldNames.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append(",val);" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + codeGeneratorVariable_Prefix + "			return ht;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		/** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZCustomCode()
{ return BUZCustomCode(string.Empty);}
public static string EntityIncludes(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 

	/*string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}
	
	 

*/
 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string EntityIncludes()
{ return EntityIncludes(string.Empty);}
public static string BOEditControlToRow(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;
		
								
		//overriding entity.
		Entity entityBOPage =  RepositoryManager.Instance.Entities["BOPage",entity.Name];
		Entity entityBOEditPage =  RepositoryManager.Instance.Entities["BOEditPage",entity.Name];
		if(entityBOPage != null)
		{
			entityBOPage.OverridingEntity = entityBOEditPage;
		}
		entity.OverridingEntity = entityBOPage;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected void ControlToRow(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Paper row)" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


            foreach(string entityFieldKey in entity.Fields.Keys)
            {
                Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


				if(!displayed)
				{
					continue;
				}
				if(dataType == "shortbinary" || dataType == "binary")
				{
					//will handle it later
					continue;
				}
				
				if(!(isNative && !tokenEnabled && !autoIncreament))
				{
					continue;
				}
				codeGeneratorVariable_DisplayCode.Append(Environment.NewLine + Environment.NewLine);
				string usedControl = (listTable == string.Empty)? webControl: listControl;
				string strNullable = (isValueType)? "?": string.Empty;
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			//**");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			/** Custom Region Start [ControlToRow(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append(")] **/" + "\r\n" + codeGeneratorVariable_Prefix + "			row.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(" = (" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(".Value != null) ? " + "\r\n" + codeGeneratorVariable_Prefix + "				Convert.To");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpFrameworkDataType);

codeGeneratorVariable_DisplayCode.Append("(" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(".Value) :" + "\r\n" + codeGeneratorVariable_Prefix + "				(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(strNullable);

codeGeneratorVariable_DisplayCode.Append(")null;" + "\r\n" + codeGeneratorVariable_Prefix + "			/** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

	
            }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BOEditControlToRow()
{ return BOEditControlToRow(string.Empty);}
public static string BOListPopulateSearchPanel(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


				
		//overriding entity.
		Entity entityBOPage =  RepositoryManager.Instance.Entities["BOPage",entityName];
		Entity entityBOListSearch =  RepositoryManager.Instance.Entities["BOListSearch",entityName];
		if(entityBOPage != null)
		{
			entityBOPage.OverridingEntity = entityBOListSearch;
		}
		entity.OverridingEntity = entityBOPage;
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        public void PopulateSearchPanel()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        {");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" col = GetBOCollectionForList() as " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "            if (!Page.IsPostBack)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				//we can remove this check because Populating of search panel occurs only when isPostBack ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				//property is false.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				PopulateListControls();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			FilterPair.Clear();");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


            foreach(string entityFieldKey in entity.Fields.Keys)
            {
                Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";



				codeGeneratorVariable_DisplayCode.Append(Environment.NewLine + Environment.NewLine);
                if(dataType!="shortbinary" && dataType!="binary" && displayed)
                {
					 string usedControl = (listTable == string.Empty)? webControl: listControl;
					 if(!usingRange)
					 {
					  string strFrom = (usingTime)? "_From": string.Empty;
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//**");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            if (col.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(strFrom);

codeGeneratorVariable_DisplayCode.Append(" != null)" + "\r\n" + codeGeneratorVariable_Prefix + "            {");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(".Value = " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(strDecimalCast);

codeGeneratorVariable_DisplayCode.Append(" col." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(strFrom);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "			    FilterPair.Add(new Pair(lbl");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(".Text, " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(".Text));" + "\r\n" + codeGeneratorVariable_Prefix + "            }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			else");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(".Value = null;" + "\r\n" + codeGeneratorVariable_Prefix + "			} ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


					}
					else //using range
					{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//**");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			if (col.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_From != null)" + "\r\n" + codeGeneratorVariable_Prefix + "            {");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_From.Value = " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(strDecimalCast);

codeGeneratorVariable_DisplayCode.Append(" col." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_From;" + "\r\n" + codeGeneratorVariable_Prefix + "			    FilterPair.Add(new Pair(lbl");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_From.Text, " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_From.Text));" + "\r\n" + codeGeneratorVariable_Prefix + "            }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			else");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_From.Value = null;" + "\r\n" + codeGeneratorVariable_Prefix + "			} ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			if (col.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_To != null)" + "\r\n" + codeGeneratorVariable_Prefix + "            {");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_To.Value = " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(strDecimalCast);

codeGeneratorVariable_DisplayCode.Append(" col." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_To;" + "\r\n" + codeGeneratorVariable_Prefix + "			    FilterPair.Add(new Pair(lbl");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_To.Text, " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_To.Text));" + "\r\n" + codeGeneratorVariable_Prefix + "            }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			else");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(FreeHash.ControlPrefix[usedControl]);

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_To.Value = null;" + "\r\n" + codeGeneratorVariable_Prefix + "			} ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


					} 
		    	}  
            }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "            /** Custom Region Start [PopulateSearchPanel] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            /** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}	");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BOListPopulateSearchPanel()
{ return BOListPopulateSearchPanel(string.Empty);}
public static string BOListWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Configuration;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.Security;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI.WebControls;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI.WebControls.WebParts;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Web.UI.HtmlControls;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode.PresentationLayer;	");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


		codeGeneratorVariable_DisplayCode.Append(GeneralUsing() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "namespace ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(RepositoryManager.Instance.Repository.ProjectName);

codeGeneratorVariable_DisplayCode.Append(".Aspx." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(accessorName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	public partial class ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("List : ListParentPage,IListPage" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		/** Custom Region Start [Main] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        /** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public void SearchFrameWindow_OnInit(object sender, EventArgs e)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			/** Custom Region Start [SearchFrameWindow_OnInit] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			/** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        protected override void OnLoad(EventArgs e)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//**register handlers for multirows actions");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			OnSelectedRowAction += new OnSelectedRowActionDelegate(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("List_OnSelectedRowAction);" + "\r\n" + codeGeneratorVariable_Prefix + "			OnSelectedRowsActionComplete += new OnSelectedRowsActionCompleteDelegate(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("List_OnSelectedRowsActionComplete);" + "\r\n" + codeGeneratorVariable_Prefix + "			OnSelectedRowsActionFailed += new OnSelectedRowsActionFailedDelegate(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("List_OnSelectedRowsActionFailed);    " + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//**set grid key here.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			Grid.DataKeyNames = new string[] {");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				string qoma="";			  
                foreach(string keyField in gridKey.Split(','))
                {
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(qoma);

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.ConstantNStatic(keyField));

codeGeneratorVariable_DisplayCode.Append("" + "" + "");


					qoma = ","; 
                }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			};");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			/** Custom Region Start [OnLoad] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			/** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			base.OnLoad(e);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        }	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		 codeGeneratorVariable_DisplayCode.Append(BOListPopulateListControls() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BOListPopulateBOCollection() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BOListRowToControl() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		#region IListPage Members");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		codeGeneratorVariable_DisplayCode.Append(BOListPopulateSearchPanel() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		BusinessObjectCollection IPage.BOCollection");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				BusinessObjectCollection col = ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Collection.NewInstance;" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				/** Custom Region Start [BOCollection] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				//--set default sorting.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				col.SortedBy = \"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(gridSortedBy);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "				//--set paging params if required.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				col.AllowPaging = true;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				//col.PageSize = 2;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				/** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "				return col;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public string EntityName");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return \"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityName);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		public string ResourceName");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "				return \"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public GridView Grid");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return gv");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		public IPager Pager");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return pager");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(";" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		public IButtonControl SearchButton");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return btnSearch; ;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		public new string Title");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ResourceProvider.GetResourceString(ResourceName,\"PageTitle\");");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public MultiView MVSearchResult");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return mvSearchResult;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		public MultiView MVMessage");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return mvMessage;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "    #endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		/** Custom Region Start [DeleteRow] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        public void DeleteRow(DataKey dataKey,bool transactionBased)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Collection col = " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Collection.Instance;" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


					foreach(string keyField in gridKey.Split(','))
					{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				col[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.ConstantNStatic(keyField));

codeGeneratorVariable_DisplayCode.Append("] = dataKey[" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.ConstantNStatic(keyField));

codeGeneratorVariable_DisplayCode.Append("];" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


									qoma = ","; 
								}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				col.DeleteRecords();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        /** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Event Handlers");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected void btnSearch_Click(object sender, EventArgs e)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			PopulateBOCollection();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			if (Pager != null)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				BusinessObjectCollection col = GetBOCollectionForList();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				Pager.TotalRecords = col.GetRecordCount();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				Pager.CurrentPageNumber = col.PageNumber = 1;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			BindData();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected void gv");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("_RowDataBound(object sender, GridViewRowEventArgs e)" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			switch (e.Row.RowType)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				case DataControlRowType.DataRow:");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow row = ((DataRowView)e.Row.DataItem).Row as " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow;" + "\r\n" + codeGeneratorVariable_Prefix + "					   RowToControl(e.Row, row);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					   /** Custom Region Start [Grid_RowDataBound(DataRow)] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					   /** Custom Region End **/ ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				break;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "				case DataControlRowType.Header:");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					   /** Custom Region Start [Grid_RowDataBound(Header)] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					   /** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				break;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		protected void gv");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("_RowCommand(object sender, GridViewCommandEventArgs e)" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			int rowIndex = 0;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			GridView grid = sender as GridView;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			DataKey dataKey = null;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			if (e.CommandArgument != null &&");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				int.TryParse(e.CommandArgument.ToString(), out rowIndex) && ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				rowIndex >= 0 && rowIndex <= grid.Rows.Count)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				dataKey = grid.DataKeys[rowIndex];");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			switch(e.CommandName)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				case \"Edit\":");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					string queryString = string.Empty; ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				string seperator = " + \"&\" + ";
				if(gridKey!=string.Empty)
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					queryString =  ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

			  
					string[] strs=gridKey.Split(',');
					for(int i=0;  i<strs.Length; i++)
					{
						string keyField = strs[i];
						if(i == strs.Length-1)
						{
							seperator = ";";
						}
codeGeneratorVariable_DisplayCode.Append("		" + "\r\n" + codeGeneratorVariable_Prefix + "						string.Format(\"{0}={1}\",");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.ConstantNStatic(keyField));

codeGeneratorVariable_DisplayCode.Append("," + "\r\n" + codeGeneratorVariable_Prefix + "							dataKey[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(StringProcessor.ConstantNStatic(keyField));

codeGeneratorVariable_DisplayCode.Append("]) " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(seperator);

codeGeneratorVariable_DisplayCode.Append("" + "" + "");


						 
					}
					
				}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "					Response.Redirect(string.Format(\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Edit.aspx?Update=true&{0}\",queryString),true);" + "\r\n" + codeGeneratorVariable_Prefix + "					break;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				case \"Delete\":");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					DeleteRow(dataKey,false);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					DoOnSuccessfullDelete();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					break;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				/** Custom Region Start [Grid_RowCommand] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				/** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected void gv");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("_RowCreated(object sender, GridViewRowEventArgs e)" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			switch (e.Row.RowType)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				case DataControlRowType.DataRow:");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					//delete button");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					ImageButton btnDelete = e.Row.FindControl(\"btnDelete\") as ImageButton;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					btnDelete.Attributes.Add(\"onclick\",");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						string.Format(\"if (!confirm('{0}')) return false;\",");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							ResourceProvider.GetGeneralResourceString(\"Message_WantToDeleteThis\")));");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "					/** Custom Region Start [Grid_RowCreated(DataRow)] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    /** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					break;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "				case DataControlRowType.Header:");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					//delete selected button");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					ImageButton btnDeleteSelected = e.Row.FindControl(\"btnDeleteSelected\") as ImageButton;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					btnDeleteSelected.Attributes.Add(\"onclick\",");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						string.Format(\"if (!InTableApplyCheckboxSelectionChecks(document.getElementById('{1}')) || !confirm('{0}')) return false;\",");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							ResourceProvider.GetGeneralResourceString(\"Message_WantToDeleteSelected\"),");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                               Grid.ClientID));");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "					/** Custom Region Start [Grid_RowCreated(Header)] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    /** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					break;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		public void gv");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("_RowEditing(object sender, GridViewEditEventArgs e)" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		public void gv");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("_RowDeleting(object sender, GridViewDeleteEventArgs e)" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected void btnWordExport_Click(object sender, ImageClickEventArgs e)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ExportListTo(ExportFormat.Word);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected void btnExcelExport_Click(object sender, ImageClickEventArgs e)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ExportListTo(ExportFormat.Excel);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		private void DoOnSuccessfullDelete()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			Response.Redirect(\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("List.aspx\",true);" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		private void DoOnSuccessfullMultiDelete()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			Response.Redirect(\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("List.aspx\",true);" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		void ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("List_OnSelectedRowsActionFailed(string actionName)" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			/** Custom Region Start [List_OnSelectedRowsActionFailed] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            switch (actionName)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				case \"DeleteSelected\":");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					DataAccessor.RollbackTransaction();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					break;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            /** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		void ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("List_OnSelectedRowsActionComplete(string actionName)" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			/** Custom Region Start [List_OnSelectedRowsActionComplete] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            switch (actionName)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				case \"DeleteSelected\":");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					DataAccessor.CommitTransaction();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					break;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            /** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		void ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("List_OnSelectedRowAction(string actionName, DataKey key)" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			/** Custom Region Start [List_OnSelectedRowAction] **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            switch (actionName)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				case \"DeleteSelected\":");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					DeleteRow(key, true);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					break;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            /** Custom Region End **/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BOListWholeClass()
{ return BOListWholeClass(string.Empty);}
public static string ResourceBOListWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


		entity.OverridingEntity = RepositoryManager.Instance.Entities["BOPage",entityName];
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "<root>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  <!-- ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    Microsoft ResX Schema ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    Version 2.0");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    The primary goals of this format is to allow a simple XML format ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    that is mostly human readable. The generation and parsing of the ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    various data types are done through the TypeConverter classes ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    associated with the data types.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    Example:");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    ... ado.net/XML headers & schema ...");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <resheader name=\"version\">2.0</resheader>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        <value>[base64 mime encoded serialized .NET Framework object]</value>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    </data>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        <comment>This is a comment</comment>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    </data>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    There are any number of \"resheader\" rows that contain simple ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    name/value pairs.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    Each data row contains a name, and value. The row also contains a ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    type or mimetype. Type corresponds to a .NET class that support ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    text/value conversion through the TypeConverter architecture. ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    Classes that don't support this are serialized and stored with the ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    mimetype set.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    The mimetype is used for serialized objects, and tells the ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    ResXResourceReader how to depersist the object. This is currently not ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    extensible. For a given mimetype the value must be set accordingly:");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    Note - application/x-microsoft.net.object.binary.base64 is the format ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    that the ResXResourceWriter will generate, however the reader can ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    read any of the formats listed below.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    mimetype: application/x-microsoft.net.object.binary.base64");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    value   : The object must be serialized with ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            : and then encoded with base64 encoding.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    mimetype: application/x-microsoft.net.object.soap.base64");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    value   : The object must be serialized with ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            : and then encoded with base64 encoding.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "    mimetype: application/x-microsoft.net.object.bytearray.base64");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    value   : The object must be serialized into a byte array ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            : using a System.ComponentModel.TypeConverter");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            : and then encoded with base64 encoding.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    -->");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "      <xsd:complexType>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        <xsd:choice maxOccurs=\"unbounded\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "          <xsd:element name=\"metadata\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            <xsd:complexType>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "              <xsd:sequence>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "              </xsd:sequence>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "              <xsd:attribute name=\"type\" type=\"xsd:string\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "              <xsd:attribute ref=\"xml:space\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            </xsd:complexType>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "          </xsd:element>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "          <xsd:element name=\"assembly\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            <xsd:complexType>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "              <xsd:attribute name=\"alias\" type=\"xsd:string\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "              <xsd:attribute name=\"name\" type=\"xsd:string\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            </xsd:complexType>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "          </xsd:element>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "          <xsd:element name=\"data\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            <xsd:complexType>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "              <xsd:sequence>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "              </xsd:sequence>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "              <xsd:attribute ref=\"xml:space\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            </xsd:complexType>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "          </xsd:element>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "          <xsd:element name=\"resheader\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            <xsd:complexType>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "              <xsd:sequence>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "              </xsd:sequence>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            </xsd:complexType>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "          </xsd:element>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        </xsd:choice>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "      </xsd:complexType>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    </xsd:element>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  </xsd:schema>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  <resheader name=\"resmimetype\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <value>text/microsoft-resx</value>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  </resheader>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  <resheader name=\"version\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <value>2.0</value>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  </resheader>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  <resheader name=\"reader\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  </resheader>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  <resheader name=\"writer\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  </resheader>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  <!-- Custom Region Start [Common] -->");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  <data name=\"PageTitle\" xml:space=\"preserve\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <value>");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityCaption);

codeGeneratorVariable_DisplayCode.Append("</value>" + "\r\n" + codeGeneratorVariable_Prefix + "  </data>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  <data name=\"ResultFrameTitle\" xml:space=\"preserve\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <value>Search Result</value>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  </data>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  <data name=\"SearchFrameTitle\" xml:space=\"preserve\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <value>Search ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityCaption);

codeGeneratorVariable_DisplayCode.Append("</value>" + "\r\n" + codeGeneratorVariable_Prefix + "  </data>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  <data name=\"EditFrameTitle\" xml:space=\"preserve\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <value>Add/Edit ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityCaption);

codeGeneratorVariable_DisplayCode.Append("</value>" + "\r\n" + codeGeneratorVariable_Prefix + "  </data>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  <!-- Custom Region End --> ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


	try
	{
		foreach(string entityFieldKey in entity.Fields.Keys)
		{
			Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = entityField.Caption;
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isValueType=entityField.IsValueType;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];
	
	//Custom fields
	string formatString=entityField.FormatString;
	
	string listTable=entityField.ListTable;
	string listTableClassName=StringProcessor.Class(entityField.ListTable) + "BO";
	string listTableCollectionName= listTableClassName + "Collection";
	
	string listTableDisplayFields=entityField.ListTableDisplayFields;
	string listControl=entityField.ListControl;
	string webControl=entityField.WebControl;
	string listTableKeyField=entityField.ListTableKeyField;
	string listTableKeyFieldProperty=StringProcessor.Property(entityField.ListTableKeyField);
	string listTableKeyFieldConstant=StringProcessor.ConstantNStatic(entityField.ListTableKeyField);
	string strReadOnly = (entityField.ReadOnly)? "true": "false";
	
	bool usingRange = entityField.UsingRange;
	bool displayed = entityField.Displayed;
	bool usingTime = entityField.UsingTime;
		
	string strIsDecimalNumberAttb = (listTable == string.Empty && (dataType == Constants.UDTypes.SHORT ||
		dataType == Constants.UDTypes.LONG || 
		dataType == Constants.UDTypes.INT ||
		dataType == Constants.UDTypes.BYTE))? "IsDecimalNumber = \"false\"": string.Empty;
		
	string strUsingTimeAttb =(usingTime)? "ShowingTime=\"true\"": string.Empty;
	string strDecimalCast = (isValueType && dataType != Constants.UDTypes.DATE_TIME && dataType != Constants.UDTypes.BIT)?
					"(decimal?)": "";


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  <!-- Custom Region Start [Field(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(")] -->" + "\r\n" + codeGeneratorVariable_Prefix + "  <data name=\"Field_");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("\" xml:space=\"preserve\">" + "\r\n" + codeGeneratorVariable_Prefix + "    <value>");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldCaption);

codeGeneratorVariable_DisplayCode.Append("</value>" + "\r\n" + codeGeneratorVariable_Prefix + "  </data>");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

	
			if(isRange)
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  <data name=\"Field_");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_To\" xml:space=\"preserve\">" + "\r\n" + codeGeneratorVariable_Prefix + "    <value>");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldCaption);

codeGeneratorVariable_DisplayCode.Append(" To</value>" + "\r\n" + codeGeneratorVariable_Prefix + "  </data>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  <data name=\"Field_");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_From\" xml:space=\"preserve\">" + "\r\n" + codeGeneratorVariable_Prefix + "    <value>");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldCaption);

codeGeneratorVariable_DisplayCode.Append(" From</value>" + "\r\n" + codeGeneratorVariable_Prefix + "  </data>");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  <!-- Custom Region End] -->");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
    }
    catch(Exception ex)
    {
		throw Logger.Write(ex);
    }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "<!-- Custom Region Start [Extra] -->");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "<!-- Custom Region End -->  ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "</root>");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string ResourceBOListWholeClass()
{ return ResourceBOListWholeClass(string.Empty);}
public static string BUZDataSetStaticMetods(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region Static Methods");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		private static void CreateDataSet(DataSet ds)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		DataTable dtParent,dtChild;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//****** Adding Tables to DataSet ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				foreach(string key in RepositoryManager.Instance.Entities.Keys)
				{ 
					Entity entity = RepositoryManager.Instance.Entities[key];

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		ds.Tables.Add(new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable());" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "		//****** Adding Relations to DataSet ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		DataColumn[] parentColumns,childColumns;		");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				foreach(string key in RepositoryManager.Instance.Entities.Keys)
				{ 
					Entity entity = RepositoryManager.Instance.Entities[key];

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


					foreach(string relKey in  entity.Children.Keys)
					{   
						Entity.Relation relation = entity.Children[relKey];

string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;


						Entity refEntity = relation.ReferencedEntity;

string refClassName=  StringProcessor.Class(refEntity.Name) + "BO";
    string refCollectionName=  refClassName + "Collection";
	string refEntityName=  refEntity.Name;
	string refEntityCaption = refEntity.Caption;
	string refEntityVariable = StringProcessor.Variable(refEntity.Name);
	string refTableName=refEntity.TableName; 
	string refViewName=refEntity.ViewName;
	string refKeySignature=refEntity.KeySignature;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(childRelationName);

codeGeneratorVariable_DisplayCode.Append("]" + "\r\n" + codeGeneratorVariable_Prefix + "		parentColumns=new DataColumn[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refKey.Length);

codeGeneratorVariable_DisplayCode.Append("];" + "\r\n" + codeGeneratorVariable_Prefix + "		childColumns =new DataColumn[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refKey.Length);

codeGeneratorVariable_DisplayCode.Append("];;" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		dtParent=ds.Tables[\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityName);

codeGeneratorVariable_DisplayCode.Append("\"];" + "\r\n" + codeGeneratorVariable_Prefix + "		dtChild=ds.Tables[\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refEntityName);

codeGeneratorVariable_DisplayCode.Append("\"];" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


						for(int i=0; i<refKey.Length; i++)
						{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		parentColumns[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(i);

codeGeneratorVariable_DisplayCode.Append("] = dtParent.Columns[\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(nativeKey[i].Name);

codeGeneratorVariable_DisplayCode.Append("\"];" + "\r\n" + codeGeneratorVariable_Prefix + "		childColumns[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(i);

codeGeneratorVariable_DisplayCode.Append("] = dtChild.Columns[\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refKey[i].Name);

codeGeneratorVariable_DisplayCode.Append("\"];" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


						}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		ds.Relations.Add(\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(childRelationName);

codeGeneratorVariable_DisplayCode.Append("\",parentColumns,childColumns);" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


					}  
				}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZDataSetStaticMetods()
{ return BUZDataSetStaticMetods(string.Empty);}
public static string BUZDataSetInnerClasses(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "\r\n" + codeGeneratorVariable_Prefix + "		#region Inner Classes");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public class TableNames");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			foreach(string key in RepositoryManager.Instance.Entities.Keys)
			{ 
				Entity entity = RepositoryManager.Instance.Entities[key];

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			public const string ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(" = \"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityName);

codeGeneratorVariable_DisplayCode.Append("\";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public class RelationNames");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			foreach(string key in RepositoryManager.Instance.Entities.Keys)
			{ 
				Entity entity = RepositoryManager.Instance.Entities[key];
				foreach(string relKey in  entity.Parents.Keys)
				{   
					Entity.Relation relation = entity.Parents[relKey];

string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			public const string ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(parentRelationProperty);

codeGeneratorVariable_DisplayCode.Append(" = \"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(parentRelationName);

codeGeneratorVariable_DisplayCode.Append("\";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				} 
			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZDataSetInnerClasses()
{ return BUZDataSetInnerClasses(string.Empty);}
public static string BOCommonWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 

codeGeneratorVariable_DisplayCode.Append(GeneralUsing() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "namespace ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(RepositoryManager.Instance.Repository.ProjectName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	public class BOCommon");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		private static Hashtable s_htBOTypes;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		 codeGeneratorVariable_DisplayCode.Append(BOCommonStaticMetods() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BOCommonWholeClass()
{ return BOCommonWholeClass(string.Empty);}
public static string LoginCodeBehind(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public partial class Login : System.Web.UI.Page");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				   {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					   protected void Page_Load(object sender, EventArgs e)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					   {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "					   }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					   protected void btnLogin_Click(object sender, EventArgs e)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					   {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						   bool isPersistent = true;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						   IUserLogin userLogin = BOCommon.GetUserLogin();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						   //---testing encrypting functionality.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						   //string str=DataEncryptor.Instance.GetEncryptedString(\"AbdulWahid\");");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						   //DataEncryptor.Instance.GetDecryptedString(str);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						   IUser user = userLogin.AuthenticateUser(txtLogin.Text, txtPassword.Text);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						   if (user != null)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						   {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							   //authentication succeeded.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							   UserProfile.Instance.User = user;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							   FormsAuthenticationTicket ticket =");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								   new FormsAuthenticationTicket(user.UserId, isPersistent, 20);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							   // Encrypt the ticket.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							   string encTicket = FormsAuthentication.Encrypt(ticket);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "							   // Create the cookie.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							   Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "							   // Redirect back to original URL.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							   Response.Redirect(FormsAuthentication.GetRedirectUrl(user.UserId, isPersistent));");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "						   }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						   else");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						   {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							   lblErrorMessage.Text= ResourceProvider.GetGeneralResourceString(\"Message_LoginFailed\");");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							   //authentication failed.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						   }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					   }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				   }");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string LoginCodeBehind()
{ return LoginCodeBehind(string.Empty);}
public static string BUZDataTableWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


		codeGeneratorVariable_DisplayCode.Append(GeneralUsing() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "namespace ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(RepositoryManager.Instance.Repository.ProjectName);

codeGeneratorVariable_DisplayCode.Append(".BusinessObjects." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(accessorName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	public class ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable:DataTable,System.Collections.IEnumerable" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		 codeGeneratorVariable_DisplayCode.Append(BUZDateTableMembers() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZDataTableStaticMethods() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	public class ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow:DataRow" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		 codeGeneratorVariable_DisplayCode.Append(BUZDateRowMembers() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZDataTableWholeClass()
{ return BUZDataTableWholeClass(string.Empty);}
public static string SitemapWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "\r\n" + codeGeneratorVariable_Prefix + "<siteMap resourceClass =\"SiteMapResource\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  <siteMapNode name=\"rootNode\" >");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <siteMapNode name=\"Home\" url=\"~/Default.aspx\"  />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    <siteMapNode name=\"Entities\">");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			foreach(string key in RepositoryManager.Instance.Entities.Keys)
			{ 
				Entity entity = RepositoryManager.Instance.Entities[key];

string className=  StringProcessor.Class(entity.Name) + "BO";
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = entity.Caption;
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;
	//Custom fields
	string gridKey=entity.GridKey;
	string gridSortedBy=entity.GridSortedBy;
	string newButtonAttributes=entity["newButtonAttributes",true]; 
	string searchButtonsPanelAttributes=entity["searchButtonsPanelAttributes",true];
    string searchButtonAttributes = entity["searchButtonAttributes",true];  
	
	//Security
	Repository.Security security=Managers.RepositoryManager.Instance.Repository.SecurityRelated;
	bool isLoginFeatureIgnored = (entity["isLoginFeatureIgnored"] == "true")? true: false;
    string iUserImplement = string.Empty;
	string iUserLoginImplement = string.Empty;
	string iRoleImplement = string.Empty;
	Repository.Security.UserRole userRole=null;
	Repository.Security.UserLogin userLogin=null;
	bool isUserLoginClass= false;
	bool isUserRoleClass= false;
	string userClass=string.Empty; 
	string roleClass=string.Empty;
	string users_rolesClass =string.Empty; 
	string roles_modulesClass =string.Empty;
	
	string userCollection=string.Empty; 
	string roleCollection=string.Empty;
	string users_rolesCollection =string.Empty; 
	string roles_modulesCollection =string.Empty;

	
	if(security != null)
	{
		userLogin = security.UserLoginInfo;
		userRole = security.UserRoleInfo;
		
		userClass = StringProcessor.Class(userLogin.Entity) + "BO";
		roleClass = StringProcessor.Class(userRole.Entity) + "BO"; 
		users_rolesClass = StringProcessor.Class(userLogin.RelatedRolesEntity) + "BO";
		roles_modulesClass = StringProcessor.Class(userRole.relatedModulesEntity) + "BO";
		
		userCollection=userClass + "Collection"; 
		roleCollection=roleClass + "Collection";
		users_rolesCollection =users_rolesClass + "Collection"; 
		roles_modulesCollection =roles_modulesClass + "Collection";


	
		if(security.UserLoginInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iUserImplement = ",IUser";
			iUserLoginImplement = ",IUserLogin";
			isUserLoginClass=true;
		 }
		 else if(security.UserRoleInfo.Entity.ToUpper()== entityName.ToUpper())
		 {
			iRoleImplement = ",IRole";
			isUserRoleClass=true;
		 }
	}


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				<siteMapNode name=\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("\" url=\"~/aspx/" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(accessorName);

codeGeneratorVariable_DisplayCode.Append("/" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("List.aspx\" >" + "\r\n" + codeGeneratorVariable_Prefix + "					<siteMapNode name=\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Edit\" url=\"~/aspx/" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(accessorName);

codeGeneratorVariable_DisplayCode.Append("/" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("Edit.aspx\" isMenuItem=\"false\" />" + "\r\n" + codeGeneratorVariable_Prefix + "				</siteMapNode>			");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + codeGeneratorVariable_Prefix + "    </siteMapNode>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "  </siteMapNode>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "</siteMap>");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string SitemapWholeClass()
{ return SitemapWholeClass(string.Empty);}
public static string DefaultCodeBehind(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	public partial class Default : System.Web.UI.Page");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				   {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					   protected void Page_Load(object sender, EventArgs e)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					   {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						   if (UserProfile.Instance.User.DefaultRole != null)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							   {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                   SiteMapNode node = siteMapDataSource.Provider.FindSiteMapNodeFromKey(UserProfile.Instance.User.DefaultRole.HomeModule);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                   string url = (node != null) ? node.Url : string.Empty;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                   if (!string.IsNullOrEmpty(url))");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                   {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                       Response.Redirect(url);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                   }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                   else");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                   {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                        throw new Exception(\"Invalid home module\");");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                                   }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							   }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						   else");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						   {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							   if (UserProfile.Instance.User.DefaultRole != null)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							   {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								   Response.Redirect(UserProfile.Instance.User.DefaultRole.HomeModule);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							   }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							   else");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							   {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								   throw new Exception(\"Please define default page which have to be displayed after logged in\");");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "								   //hardcode here default page.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "							   }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "						   }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					   }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				   }");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string DefaultCodeBehind()
{ return DefaultCodeBehind(string.Empty);}
}}
